-
Notifications
You must be signed in to change notification settings - Fork 41
Converter PLM dispatch #773
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
Draft
jaredthomas68
wants to merge
28
commits into
NatLabRockies:develop
Choose a base branch
from
jaredthomas68:control-converter
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18,048
−17,535
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
19ff6e1
initial example files for plm for a converter
jaredthomas68 d026a8a
run converter plm with single demand profile
jaredthomas68 c653a77
merge from develop
jaredthomas68 c1564c2
Merge branch 'develop' into control-converter
jaredthomas68 1d80254
have precommit ignore demand profiles for converter plm example
jaredthomas68 bcd95c2
peak load converter working with multiple demand profiles
jaredthomas68 d58cbf9
minor plot updates
jaredthomas68 0f99537
remove incorrect comments
jaredthomas68 3d7dc9c
add key file that was missed earlier
jaredthomas68 3b2fdfd
include init file
jaredthomas68 eafbf14
update units/naming
jaredthomas68 d885c12
bugfix, grap element instead of array
jaredthomas68 b964811
Merge branch 'develop' into control-converter
kbrunik 19b84f9
include price dispatch capability to converter demand control
jaredthomas68 6193c9a
Merge remote-tracking branch 'myfork/control-converter' into control-…
jaredthomas68 1602280
wip
jaredthomas68 2afd03b
include unit definitions for peak cutoff
jaredthomas68 6296b1a
Merge branch 'develop' into control-converter
jaredthomas68 c124ecb
update naming:
jaredthomas68 b4f54ba
Fuel Cell Operational Calculations (#5)
kbrunik 7b8c33a
resolve merge conflict
jaredthomas68 8bc1616
move demand profiles for examples to library and update converter plm…
jaredthomas68 d0abe9f
put converter and storage peak load management examples in subfolders…
jaredthomas68 6c5caed
reformat and fix pre-commit hook ignores
jaredthomas68 e09472a
move heuristic plm examples to 33_peak_load_management_heuristics
jaredthomas68 fd466c6
rename run files for example 33
jaredthomas68 02ea362
update docstrings and example descriptions for plm heuristic
jaredthomas68 c448201
update descriptions
jaredthomas68 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
examples/33_peak_load_management_heuristics/plm_converter/driver_config.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| name: driver_config | ||
| description: Driver configuration for peak load management converter heuristic control | ||
| general: | ||
| folder_output: outputs | ||
| create_om_reports: false |
13 changes: 13 additions & 0 deletions
13
examples/33_peak_load_management_heuristics/plm_converter/plant_config.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| name: plant_config | ||
| description: Plant configuration for peak load management converter heuristic control | ||
| plant: | ||
| plant_life: 30 | ||
| simulation: | ||
| n_timesteps: 8760 | ||
| dt: 3600 | ||
| timezone: -6 | ||
| start_time: 2025/07/01 00:00:00 | ||
| technology_interconnections: | ||
| - [hydrogen_feedstock, fuel_cell, hydrogen, pipe] | ||
| - [fuel_cell, electrical_load_demand, [electricity_out, electricity_in]] | ||
| - [electrical_load_demand, grid_buy, [unmet_electricity_demand_out, electricity_set_point]] |
101 changes: 101 additions & 0 deletions
101
examples/33_peak_load_management_heuristics/plm_converter/run_peak_load_management.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| """ | ||
| Example 33: Peak load management converter heuristic dispatch | ||
|
|
||
| This example demonstrates peak load management dispatch open loop control of a converter | ||
| with two demand profiles of interest | ||
|
|
||
| In this example, the fuel-cell converter command is determined by a simple open-loop | ||
| threshold heuristic that uses two profiles: | ||
|
|
||
| 1. demand_profile (local set-point) | ||
| 2. demand_profile_upstream (supervisory or upstream signal) | ||
|
|
||
| At each time step, dispatch is only considered when either profile exceeds its configured | ||
| cutoff. For electricity-mode upstream control, the commanded dispatch is based on the | ||
| larger exceedance of the two profiles and is then limited by both the instantaneous local | ||
| demand and converter capacity. This creates a peak-shaving command profile for the | ||
| converter without storage state-of-charge dynamics or optimization. | ||
|
|
||
| The output figure compares the original local demand, upstream demand, cutoff thresholds, | ||
| converter output, resulting unmet demand, and grid purchases. | ||
|
|
||
| """ | ||
|
|
||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| from h2integrate import H2IntegrateModel | ||
| from h2integrate.core.utilities import build_time_series_from_plant_config | ||
|
|
||
|
|
||
| # Create, setup, and run the H2Integrate model | ||
| model = H2IntegrateModel("33_plm_converter_heuristic.yaml") | ||
|
|
||
| model.setup() | ||
| # om.n2(model.prob) | ||
| model.run() | ||
| model.post_process() | ||
|
|
||
| demand_profile = model.prob.get_val("fuel_cell.electricity_command_value", units="kW") | ||
| # plot the results for the first week | ||
| demand_profile_upstream = np.array( | ||
| model.technology_config["technologies"]["fuel_cell"]["model_inputs"]["control_parameters"][ | ||
| "demand_profile_upstream" | ||
| ] | ||
| ) | ||
| demand_profile_peak_cutoff = model.technology_config["technologies"]["fuel_cell"]["model_inputs"][ | ||
| "control_parameters" | ||
| ]["demand_profile_peak_cutoff"] | ||
| demand_profile_upstream_peak_cutoff = model.technology_config["technologies"]["fuel_cell"][ | ||
| "model_inputs" | ||
| ]["control_parameters"]["demand_profile_upstream_peak_cutoff"] | ||
| grid_output = model.prob.get_val("grid_buy.electricity_out", units="MW") | ||
|
|
||
| time_series = build_time_series_from_plant_config(model.plant_config) | ||
|
|
||
| n_plot = 24 * 7 | ||
| time_plot = time_series[:n_plot] | ||
|
|
||
| fig, ax = plt.subplots(3, 1, sharex=True, figsize=(10, 5)) | ||
| ax[0].plot(time_plot, demand_profile_upstream[:n_plot] * 1e-3, label="Upstream demand") | ||
| ax[0].plot(time_plot, demand_profile[:n_plot] * 1e-3, label="Original demand") | ||
| ax[0].axhline( | ||
| demand_profile_peak_cutoff * 1e-3, label="Demand peak cutoff", color="k", linestyle="--" | ||
| ) | ||
| ax[0].axhline( | ||
| demand_profile_upstream_peak_cutoff * 1e-3, | ||
| label="Upstream demand peak cutoff", | ||
| color="k", | ||
| linestyle=":", | ||
| ) | ||
| ax[0].set(ylabel="Power (MW)", ylim=[-2, 2]) | ||
| ax[0].legend(frameon=True, ncol=3) | ||
|
|
||
| ax[1].plot(time_plot, demand_profile[:n_plot] * 1e-3, label="Original demand (MW)") | ||
| ax[1].plot( | ||
| time_plot, | ||
| model.prob.get_val("fuel_cell.electricity_out", units="MW")[:n_plot], | ||
| label="fuel_cell dispatch", | ||
| ) | ||
| ax[1].set(ylabel="Power (MW)", ylim=[-2, 2]) | ||
| ax[1].legend(frameon=False, ncol=2) | ||
|
|
||
| ax[2].plot(time_plot, demand_profile[:n_plot] * 1e-3, label="Original demand (MW)") | ||
| ax[2].plot( | ||
| time_plot, | ||
| model.prob.get_val("electrical_load_demand.unmet_electricity_demand_out", units="MW")[:n_plot], | ||
| label="New demand profile", | ||
| ) | ||
| ax[2].plot(time_plot, grid_output[:n_plot], label="Grid purchase (MW)", linestyle=":") | ||
|
|
||
| ax[2].set(ylabel="Power (MW)", ylim=[-2, 2]) | ||
| ax[2].legend(frameon=False, ncol=3) | ||
| ax[2].tick_params(axis="x", labelrotation=90) | ||
|
|
||
| for axis in ax: | ||
| axis.minorticks_on() | ||
| axis.grid(True, which="major", alpha=0.45, linewidth=0.8) | ||
| axis.grid(True, which="minor", alpha=0.2, linewidth=0.5) | ||
|
|
||
| plt.tight_layout() | ||
| plt.savefig("example_peak_load_dispatch.png", transparent=False) |
66 changes: 66 additions & 0 deletions
66
examples/33_peak_load_management_heuristics/plm_converter/tech_config.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: technology_config | ||
| description: This plant dispatches a fuel cell to reduce peak demand | ||
| technologies: | ||
| hydrogen_feedstock: | ||
| performance_model: | ||
| model: FeedstockPerformanceModel | ||
| cost_model: | ||
| model: FeedstockCostModel | ||
| model_inputs: | ||
| shared_parameters: | ||
| commodity: hydrogen | ||
| commodity_rate_units: kg/h | ||
| performance_parameters: | ||
| rated_capacity: 50.0 # kg of H2/hour | ||
| cost_parameters: | ||
| cost_year: 2022 | ||
| price: 5.0 # USD/kg H2 | ||
| annual_cost: 0. | ||
| start_up_cost: 0.0 | ||
| fuel_cell: | ||
| performance_model: | ||
| model: LinearH2FuelCellPerformanceModel | ||
| cost_model: | ||
| model: H2FuelCellCostModel | ||
| control_strategy: | ||
| model: PeakLoadManagementHeuristicOpenLoopConverterController | ||
| model_inputs: | ||
| shared_parameters: | ||
| system_capacity_kw: 1000.0 | ||
| performance_parameters: | ||
| fuel_cell_efficiency_hhv: 0.50 | ||
| uptime_hours_until_eol: 80000 | ||
| cost_parameters: | ||
| capex_per_kw: 200.0 | ||
| fixed_opex_per_kw_per_year: 10.0 | ||
| variable_opex_per_kwh: 0.0 | ||
| cost_year: 2018 | ||
| control_parameters: | ||
| commodity: electricity | ||
| commodity_rate_units: kW | ||
| demand_profile: !include demand_profiles/demand_profile.yaml | ||
| demand_profile_upstream: !include demand_profiles/demand_profile_upstream.yaml | ||
| demand_profile_peak_cutoff: 400.0 | ||
| demand_profile_upstream_peak_cutoff: 1000.0 | ||
| electrical_load_demand: | ||
| performance_model: | ||
| model: GenericDemandComponent | ||
| model_inputs: | ||
| performance_parameters: | ||
| commodity: electricity | ||
| commodity_rate_units: kW | ||
| demand_profile: !include demand_profiles/demand_profile.yaml | ||
| grid_buy: | ||
| performance_model: | ||
| model: GridPerformanceModel | ||
| cost_model: | ||
| model: GridCostModel | ||
| model_inputs: | ||
| shared_parameters: | ||
| interconnection_size: 100000 | ||
| cost_parameters: | ||
| cost_year: 2024 | ||
| fixed_interconnection_cost: 0.0 | ||
| interconnection_capex_per_kw: 0.0 | ||
| interconnection_opex_per_kw: 0.0 | ||
| electricity_buy_price: 0.09 |
5 changes: 5 additions & 0 deletions
5
examples/33_peak_load_management_heuristics/plm_storage/33_plm_storage_heuristic.yaml
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's update name of this file so it's not the same as the storage PLM file.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| name: H2Integrate_config | ||
| system_summary: Peak load management dispatch | ||
| driver_config: driver_config.yaml | ||
| technology_config: tech_config.yaml | ||
| plant_config: plant_config.yaml |
5 changes: 5 additions & 0 deletions
5
examples/33_peak_load_management_heuristics/plm_storage/driver_config.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| name: driver_config | ||
| description: Driver configuration for peak load management storage heuristic control | ||
| general: | ||
| folder_output: outputs | ||
| create_om_reports: false |
2 changes: 1 addition & 1 deletion
2
...33_peak_load_management/plant_config.yaml → ..._heuristics/plm_storage/plant_config.yaml
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
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
2 changes: 1 addition & 1 deletion
2
.../33_peak_load_management/tech_config.yaml → ...t_heuristics/plm_storage/tech_config.yaml
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| from h2integrate.control.control_strategies.converters.plm_openloop_converter_controller import ( | ||
| PeakLoadManagementHeuristicOpenLoopConverterController, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
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.
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 it could be good to have both peak load management examples (storage and converter) in the same folder
33_peak_load_managementand then have nested folders for each example.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.
Done