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

Add the new building DSM class #480

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

Add the new building DSM class #480

wants to merge 19 commits into from

Conversation

nick-harder
Copy link
Member

@nick-harder nick-harder commented Nov 12, 2024

Pull Request

Related Issue

Closes #454

Description

This add a Building DSM class and combines all residential components into one class by @HafnerMichael.

Changes Proposed

-add building class
-modify DSM naive bidding strategy
-refactor function and move common functions to DSMFlex -add tests for the building class
-some code refactoring

Testing

[Describe the testing you've done, including any specific test cases or scenarios]

Checklist

Please check all applicable items:

  • Code changes are sufficiently documented (docstrings, inline comments, doc folder updates)
  • New unit tests added for new features or bug fixes
  • Existing tests pass with the changes
  • Reinforcement learning examples are operational (for DRL-related changes)
  • Code tested with both local and Docker databases
  • Code follows project style guidelines and best practices
  • Changes are backwards compatible, or deprecation notices added
  • New dependencies added to pyproject.toml
  • A note for the release notes doc/release_notes.rst of the upcoming release is included
  • Consent to release this PR's code under the GNU Affero General Public License v3.0

Additional Notes (if applicable)

[Any additional information, concerns, or areas you want reviewers to focus on]

Screenshots (if applicable)

[Add screenshots to demonstrate visual changes]

-add buildiong class
-modify DSM naive bidding strategy
-refactor function and move common functions to DSMFlex
-add tests for the building class
-some code refactoring
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 76.89655% with 67 lines in your changes missing coverage. Please review.

Project coverage is 76.85%. Comparing base (7602914) to head (a2c33e1).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
assume/units/building.py 83.67% 32 Missing ⚠️
assume/units/steel_plant.py 44.44% 25 Missing ⚠️
assume/units/dsm_load_shift.py 72.97% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #480      +/-   ##
==========================================
+ Coverage   76.71%   76.85%   +0.14%     
==========================================
  Files          50       51       +1     
  Lines        6412     6650     +238     
==========================================
+ Hits         4919     5111     +192     
- Misses       1493     1539      +46     
Flag Coverage Δ
pytest 76.85% <76.89%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

-improve docstrings
@nick-harder nick-harder changed the title This commit add the new building DSM class Add the new building DSM class Nov 12, 2024
Copy link
Collaborator

@HafnerMichael HafnerMichael left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@nick-harder
Copy link
Member Author

@HafnerMichael there was a small mistake on your branch in the sell_to_market constraints, please compare your working branch with this one to fix the issue since it can affect your results, if you are using that feature

@HafnerMichael
Copy link
Collaborator

@HafnerMichael there was a small mistake on your branch in the sell_to_market constraints, please compare your working branch with this one to fix the issue since it can affect your results, if you are using that feature

Ok, no I dont use it there but thanks for the reminder!

unit_operator: str,
index: pd.DatetimeIndex,
bidding_strategies: dict,
components: dict[str, dict],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please check my comment at #476. In the RL scenario I faced an issue, that non RL bidding households get initialized with e.g. dict[str, PVPlant] instead of dict[str, dict]

@HafnerMichael
Copy link
Collaborator

@nick-harder I added a small example (example_01h)

Comment on lines +164 to +167
pv_profile.index = self.model.time_steps
self.components["pv_plant"][
"power_profile" if not uses_power_profile else "availability_profile"
] = pv_profile
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had to add the index here

Comment on lines +137 to +138
self.model = pyo.ConcreteModel()
self.define_sets()
Copy link
Collaborator

Choose a reason for hiding this comment

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

and to move the init of the model and its time steps up here

# Validate provided components against the list of optional technologies
for component in self.components.keys():
if component not in self.optional_technologies:
raise ValueError(
Copy link
Contributor

Choose a reason for hiding this comment

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

New looping format updated

Returns:
Orderbook: The bids consisting of the start time, end time, only hours, price and volume.
"""

# calculate the optimal operation of the unit
unit.calculate_optimal_operation_if_needed()

Copy link
Contributor

Choose a reason for hiding this comment

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

executing flexibility

Comment on lines 177 to 192

# Select the first available solver from the predefined list
solvers = check_available_solvers(*SOLVERS)
if len(solvers) < 1:
raise Exception(f"None of {SOLVERS} are available")

self.solver = SolverFactory(solvers[0])
self.solver_options = {
"output_flag": False,
"log_to_console": False,
"LogToConsole": 0,
}

self.opt_power_requirement = None
self.variable_cost_series = None

Copy link
Contributor

Choose a reason for hiding this comment

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

passing dictionary to map flexibility measure

flexibility_measure (str): Metric used to assess the building's flexibility, e.g., "max_load_shift".
"""

# List of optional technologies that a building unit can incorporate
Copy link
Contributor

Choose a reason for hiding this comment

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

container for required technologies fixed

Both variables are defined over the `time_steps` set and are continuous real numbers.
"""
self.model.variable_power = pyo.Var(self.model.time_steps, within=pyo.Reals)
self.model.variable_cost = pyo.Var(self.model.time_steps, within=pyo.Reals)
Copy link
Contributor

Choose a reason for hiding this comment

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

variable_power refactored to total_power_input

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.

Integrate "Building" unit type
3 participants