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

Feature/save soc values as a sensor #1018

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

Ahmad-Wahid
Copy link
Contributor

@Ahmad-Wahid Ahmad-Wahid commented Mar 22, 2024

Description

This PR introduces create_soc_schedule, a function to generate a state of charge (SOC) schedule from provided data. It also handles the creation or retrieval of the corresponding SOC sensor.

  • When the scheduler is instantiated with multiple=True and the flex-model passed to it includes a "soc": {"sensor": <sensor_id>}, its compute function returns a dict that includes the SoC schedule next to the power schedule.
  • Unit conversion to the unit of the SoC sensor.

Look & Feel

UI output looks like this:
image

How to test

Try to run the Toy examples(1 and 2), first add the beliefs from here and then add the schedule from here. You will see a sensor with name soc schedule and id 4. Similarly, you can see the data in timed_beliefs table.

Further Improvements

Follow-ups:

  • Test passing a fixed quantity to "soc". This should be used as the starting value, and we should throw a ValidationError if both "soc" and "soc-at-start" are passed in the flex-model).
  • Read starting value from soc sensor, plus test cases. We should make some sort of inference if the sensor had not registered a value for the exact start time of the schedule, or fail with a clear error message.
  • Test passing a time series specs to "soc". We should make some sort of inference if the specs do not contain a value for the exact start time of the schedule, or fail with a clear error message.

Related Items

Mention if this PR closes an Issue or Project.


  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

@Ahmad-Wahid Ahmad-Wahid self-assigned this Mar 27, 2024
…-soc-values-as-a-sensor

# Conflicts:
#	flexmeasures/data/models/planning/tests/test_solver.py
@Ahmad-Wahid Ahmad-Wahid requested a review from Flix6x April 5, 2024 09:02
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Thanks. It's even a bit more already than what was needed. Let's limit the scope just a little for clarity and a step-wise robust approach, and other than that I think we only need to pass some more info to the integration function.

flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/scheduling/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/utils.py Show resolved Hide resolved
flexmeasures/data/schemas/scheduling/storage.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/sensors.py Outdated Show resolved Hide resolved
flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
Flix6x and others added 10 commits May 15, 2024 16:19
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…planning/save-soc-values-as-a-sensor

Signed-off-by: F.N. Claessen <[email protected]>

# Conflicts:
#	flexmeasures/data/models/planning/storage.py
#	flexmeasures/data/schemas/scheduling/storage.py
#	flexmeasures/data/schemas/sensors.py
Signed-off-by: F.N. Claessen <[email protected]>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

I resolved some merge conflicts and updated the PR description (incl. follow-up suggestions). I hope that clarifies the scope of this PR. Can you create the follow-up tickets?

As for this PR, I suggest to leave in the commented out code that already works towards reading the starting SoC from the SoC sensor. The one code change I'd still like to see is the CLI and API initialize the scheduler with multiple=True in case the "soc" flex-model field is used. Finally, some documentation is within this PR's scope. Specifically, a changelog entry and an entry in the list of flex-model fields in features/scheduling.rst.

"soc",
type=VariableQuantityField("MWh"),
required=False,
help="State of charge (e.g sensor:<id>, or 0.328) at the start of the schedule.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
help="State of charge (e.g sensor:<id>, or 0.328) at the start of the schedule.",
# help='State of charge (e.g sensor:<id>, or "328 kWh") at the start of the schedule. If a sensor is passed, the computed schedule will also be saved to it.',
help='If a sensor (e.g sensor:<id>) recording the state of charge is passed, the computed schedule will also be saved to it.',

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.

3 participants