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

Fix storage optimisation algorithm #1343

Merged
merged 7 commits into from
Aug 31, 2023
Merged

Fix storage optimisation algorithm #1343

merged 7 commits into from
Aug 31, 2023

Conversation

noracato
Copy link
Member

New implementation of output efficiency, so it is not applied twice after calculating the curve.

Finally closes #1300

@thomas-qah
Copy link
Contributor

thomas-qah commented Jul 24, 2023

Hey @noracato! I checked out the battery-opt branch and ran rspec for it locally. Doing this returned 5 errors:

3205 examples, 5 failures, 20 pending

Failed examples:

rspec ./spec/models/qernel/merit_facade/storage_optimization_spec.rb:216 # Qernel::MeritFacade::StorageOptimization#reserve_for with a single battery with an output efficiency of 0.8 calculates the battery reserve
rspec ./spec/models/qernel/merit_facade/storage_optimization_spec.rb:223 # Qernel::MeritFacade::StorageOptimization#reserve_for with a single battery with an output efficiency of 0.8 calculates the battery load
rspec ./spec/models/qernel/merit_facade/storage_optimization_spec.rb:238 # Qernel::MeritFacade::StorageOptimization#reserve_for with a single battery with an output efficiency of 1.2 calculates the battery reserve
rspec ./spec/models/qernel/merit_facade/storage_optimization_spec.rb:245 # Qernel::MeritFacade::StorageOptimization#reserve_for with a single battery with an output efficiency of 1.2 calculates the battery load
rspec ./spec/requests/api/v3/saved_scenarios_spec.rb:107 # Saved scenarios API when fetching a single saved scenario when the saved scenario exists but the scenario does not has no data for the scenario

These seem to correspond with the error messages that semaphore currently returns (https://quintel.semaphoreci.com/jobs/059c9c4f-9bff-4e8b-a130-c630c114057d/plain_logs.txt)

Let's discuss this thursday/friday :)

@mabijkerk mabijkerk self-assigned this Aug 8, 2023
@mabijkerk

This comment was marked as outdated.

mabijkerk added a commit to quintel/merit that referenced this pull request Aug 30, 2023
…ngine#1343

Mac OS and Linux handle Ruby sort method differntly, by also sorting on the index the same sorting is forced for both operating systems
@mabijkerk
Copy link
Member

mabijkerk commented Aug 30, 2023

The difference between running the spec locally on Mac with respect locally on Linux or on Semaphore was caused by an operating system difference in the sort method of Ruby. Non-unique values are sorted in a different way by both operating systems. To counter this we have implemented a second-level attribute to the sort function, that sorts on the index as well, and therefore guarantees a stable result.

@mabijkerk
Copy link
Member

mabijkerk commented Aug 30, 2023

My test case in #1300 now produces expected results.

Blank nl2019 scenario with the following changes:

capacity_of_energy_flexibility_flow_batteries_electricity: 500.0
capacity_of_energy_power_solar_pv_solar_radiation: 15000.0
capacity_of_energy_power_wind_turbine_inland: 15000.0
settings_enable_storage_optimisation_energy_flexibility_flow_batteries_electricity: 1.0

With the following queries:

EACH(
  V(energy_flexibility_flow_batteries_electricity,"number_of_units * typical_input_capacity"),
  MAX(V(energy_flexibility_flow_batteries_electricity,electricity_input_curve))
 )

EACH(
  V(energy_flexibility_flow_batteries_electricity,"number_of_units * electricity_output_capacity"),
  MAX(V(energy_flexibility_flow_batteries_electricity,electricity_output_curve))
 )

Obtains the following results:

[
  500.00000000000006,
  500.00000000001455,
]

[
  250.00000000000003,
  250.0000000000036,
]

This is as expected: it means that the output capacity no longer has an additional cap. The output capacity realized by the algorithm is the installed output capacity and the input capacity realized is the installed input capacity. This means that we can merge this PR and the corresponding PR on quintel/merit#153.

@noracato as the results above show I'm still seeing the floating point error addressed in #1331.

Copy link
Member

@mabijkerk mabijkerk left a comment

Choose a reason for hiding this comment

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

🔋

noracato added a commit to quintel/merit that referenced this pull request Aug 31, 2023
* Limit the discharge of storage to output capacity left
On the second iteration through the dispatchables (price sensitive) max_load_at should be limited by the output capacity left, not just the output capacity

* Use output effiency as a limiting factor of charging

* Add index as second level attribute to sort_by method for quintel/etengine#1343
Mac OS and Linux handle Ruby sort method differntly, by also sorting on the index the same sorting is forced for both operating systems

---------

Co-authored-by: Mathijs Bijkerk <mathijs.bijkerk@quintel.com>
@noracato noracato merged commit dc8a38f into master Aug 31, 2023
1 check passed
@noracato noracato deleted the battery-opt branch August 31, 2023 09:59
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.

Flow battery output capacity seems to be capped below specified output capacity
3 participants