Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/34_plm_optimized_dispatch/plant_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ plant:
dt: 3600 # 1-hour timesteps
timezone: -6 # MDT (UTC-6)
start_time: 2025/01/01 00:00:00
technology_interconnections:
- [battery, electrical_load_demand, [storage_electricity_charge, electricity_demand]]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this solution but I still think we should think about adding a new storage output rather than changing the existing one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from - [battery, electrical_load_demand, [electricity_out, electricity_in]]
?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

electricity_out from storage is negative when charging and positive when discharging. Meaning that electricity_in to the demand component (which should be the electricity supplied to the demand component) would be positive and negative, which would increase the unmet_electricity_demand_out would be greater than the total demand when the battery is charging. So, actually I do think that [battery, electrical_load_demand, [electricity_out, electricity_in]] would be a feasible solution!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh what I have in PR #664 based on @vijay092 suggestion.

- [electrical_load_demand, grid_buy, [unmet_electricity_demand_out, electricity_set_point]]
- [grid_buy, battery, electricity, cable]
tech_to_dispatch_connections:
- [grid_buy, battery]
- [battery, battery]
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
]["signal_threshold_percentile"]

model.run()
model.post_process()

lmp = np.array(
model.technology_config["technologies"]["battery"]["model_inputs"]["control_parameters"][
Expand Down
8 changes: 8 additions & 0 deletions examples/34_plm_optimized_dispatch/tech_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ technologies:
energy_capex: 408 # $/kWh
power_capex: 379 # $/kW
opex_fraction: 0.025
electrical_load_demand:
performance_model:
model: GenericDemandComponent
model_inputs:
performance_parameters:
commodity: electricity
commodity_rate_units: kW
demand_profile: 0.0 # dummy demand profile to be overwritten in simulation by battery charge needs
grid_buy:
performance_model:
model: GridPerformanceModel
Expand Down
9 changes: 8 additions & 1 deletion examples/test/test_all_examples.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding more subtests! This will definitely help with any future debugging of this example if it fails!

Original file line number Diff line number Diff line change
Expand Up @@ -3027,4 +3027,11 @@ def test_plm_optimized_dispatch_example(subtests, temp_copy_of_example):
with subtests.test("Check total energy charged"):
battery_charge = model.prob.get_val("battery.storage_electricity_charge", units="kW")
total_energy_charged = battery_charge.sum() * (1 / 60) # kWh, 1 min timestep
assert pytest.approx(total_energy_charged, rel=1e-3) == -2663.0
assert pytest.approx(total_energy_charged, rel=1e-3) == 2663.0

with subtests.test("Check energy balance with battery and grid"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need more tests to make sure the wiring and energy balance is correct? Maybe this could be a follow on PR but this is good for #664.

Examples I can think of: i) No grid purchase during discharge timesteps. ii) Grid purchase equals unmet demand

battery_charge_power_series = model.prob.get_val(
"battery.storage_electricity_charge", units="kW"
)
grid_purchase_power_series = model.prob.get_val("grid_buy.electricity_out")
assert pytest.approx(battery_charge_power_series) == grid_purchase_power_series
2 changes: 1 addition & 1 deletion h2integrate/storage/storage_baseclass.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storage_commodity_out is negative when charging and positive when discharging. The charge output profile is defined as always being negative - this change will cause a lot of tests to fail. I think we could instead add another output called storage_commodity_charge_positive or something.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling this will break things in Gen's tests as well.

Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def run_storage(

# Storage specific timeseries outputs
outputs[f"storage_{self.commodity}_charge"] = np.where(
storage_commodity_out < 0, storage_commodity_out, 0
storage_commodity_out < 0, -storage_commodity_out, 0
)
outputs[f"storage_{self.commodity}_discharge"] = np.where(
storage_commodity_out > 0, storage_commodity_out, 0
Expand Down
Loading