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 7 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.

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

Potential improvements to be done in the same PR or follow up Issues/Discussions/PRs.

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

Signed-off-by: Ahmad Wahid <ahmedwahid16101@gmail.com>
Signed-off-by: Ahmad Wahid <ahmedwahid16101@gmail.com>
@Ahmad-Wahid Ahmad-Wahid self-assigned this Mar 27, 2024
Signed-off-by: Ahmad Wahid <ahmedwahid16101@gmail.com>
…-soc-values-as-a-sensor

# Conflicts:
#	flexmeasures/data/models/planning/tests/test_solver.py
Signed-off-by: Ahmad Wahid <ahmedwahid16101@gmail.com>
@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
Comment on lines 245 to 260
try:
float(value)
return value
except ValueError:
pass
return ur.Quantity(value).to(self.to_unit)
except DimensionalityError as e:
raise FMValidationError(
f"Cannot convert value `{value}` to '{self.to_unit}'"
) from e
elif (
isinstance(value, Sensor)
or isinstance(value, int)
or isinstance(value, float)
):
return value
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we'll need changes to this schema for now. SoC values passed to the new field should be sensor descriptions ({"sensor": <id>}) or strings containing a unit that is convertible to MWh (e.g. "50 kWh").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The flex model gets SoC sensor and not a dictionay . So I still need to have a check for sensor as value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about this change?

flexmeasures/data/models/planning/storage.py Outdated Show resolved Hide resolved
Signed-off-by: Ahmad Wahid <ahmedwahid16101@gmail.com>
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.

None yet

3 participants