Skip to content
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

Prevent simultaneous charge/discharge plus other minor improvements #440

Open
wants to merge 53 commits into
base: develop
Choose a base branch
from

Conversation

hdunham
Copy link
Collaborator

@hdunham hdunham commented Sep 13, 2024

Changed

  • Replace all 1/p.s.settings.time_steps_per_hour with p.hours_per_time_step for simplicity/consistency
  • Rename function add_storage_sum_constraints to add_storage_sum_grid_constraints for clarity

Added

  • Constraints to prevent simultaneous charge/discharge of storage
  • Specify in docstrings that PV max_kw and size_kw are kW-DC
  • Add the Logging package to test/Project.toml because it is used in runtests.jl

Fixed

  • Force ElectricLoad critical_load_kw to be nothing when off_grid_flag is true (critical_load_fraction was already being forced to 1, but the user was still able to get around this by providing critical_load_kw)
  • Removed looping over storage name in functions add_hot_thermal_storage_dispatch_constraints and add_cold_thermal_storage_dispatch_constraints because this loop is already done when calling these functions and storage name is passed in as argument b
  • Remove extraneous line of code in results/wind.jl
  • Change type of value_of_lost_load in FinancialInputs struct to fix convert error when user provides an Int

Copy link
Collaborator

@zolanaj zolanaj left a comment

Choose a reason for hiding this comment

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

This looks good, thanks @hdunham! I have one small question and a recommended removal which is in 2cb4b1d. I think that this is ready to merge pending the documentation build fail that I don't know how to fix at the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this addition of Logging since it's just for debugging

Comment on lines +26 to +46
@testset "Prevent simultaneous charge and discharge" begin
logger = SimpleLogger()
results = nothing
with_logger(logger) do
model = Model(optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false, "log_to_console" => false))
results = run_reopt(model, "./scenarios/simultaneous_charge_discharge.json")
end
@test any(.&(
results["ElectricStorage"]["storage_to_load_series_kw"] .!= 0.0,
(
results["ElectricUtility"]["electric_to_storage_series_kw"] .+
results["PV"]["electric_to_storage_series_kw"]
) .!= 0.0
)
) ≈ false
@test any(.&(
results["Outages"]["storage_discharge_series_kw"] .!= 0.0,
results["Outages"]["pv_to_storage_series_kw"] .!= 0.0
)
) ≈ false
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I really like this test!

Comment on lines -119 to 120
(p.production_factor[t, tz+ts-1] + p.unavailability[t][tz+ts-1]) * p.levelization_factor[t] * m[:dvMGRatedProduction][t, s, tz, ts]
(p.production_factor[t, time_step_wrap_around(tz+ts-1, time_steps_per_hour=p.s.settings.time_steps_per_hour)] + p.unavailability[t][time_step_wrap_around(tz+ts-1, time_steps_per_hour=p.s.settings.time_steps_per_hour)]) * p.levelization_factor[t] * m[:dvMGRatedProduction][t, s, tz, ts]
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the wraparound function is required for data from the initial problem (e.g., production factors and site load) and NOT required for the microgrid state of charge because that's only using the starting time period SOC from the full-year problem and then using the (tz,ts) tuple instead of an "absolute-value" time step that could otherwise exceed 8760. Is that right?

I spot-checked a case and the m[:dvStorageEnergy"] reconciles correctly for the long-duration case in the testset - just making sure I understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants