-
Notifications
You must be signed in to change notification settings - Fork 0
add stratified heat buffer #225
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
base: main
Are you sure you want to change the base?
Changes from all commits
b2875c9
ff053a8
83ff1b7
71691a1
1ede1fb
d511e89
f564c58
703f0e5
c609e4a
4f3a415
198cb9e
7612d81
86a88db
39cbbdf
c0b64b6
51310f5
77cc69c
623b700
4dc972e
1371134
1ca1295
d47c6fd
73bab55
45b2f92
05f0321
4d63fef
e357c8e
99780f0
f7b33bd
0685f57
ac27693
b491dce
d961895
3ab1f8c
721516d
edf3df5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,5 +4,5 @@ cd /D "%~dp0" | |
| cd ..\..\ | ||
| call .\venv\Scripts\activate | ||
| set PYTHONPATH=.\src\;%$PYTHONPATH% | ||
| python -m mypy ./src/ | ||
| python -m mypy ./src/omotes_simulator_core ./unit_test/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as with the linting. Why is it necessary also call mypy on the unit test? Shouldn't the pyproject.toml handle this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because the linux script also include unit test, so i just want to make sure it is similar |
||
| popd | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright (c) 2023. Deltares & TNO | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| """Module containing the Esdl to HeatBuffer asset mapper class.""" | ||
|
|
||
| from omotes_simulator_core.entities.assets.asset_abstract import AssetAbstract | ||
| from omotes_simulator_core.entities.assets.asset_defaults import HEAT_BUFFER_DEFAULTS | ||
| from omotes_simulator_core.entities.assets.esdl_asset_object import EsdlAssetObject | ||
| from omotes_simulator_core.entities.assets.heat_buffer import HeatBuffer | ||
| from omotes_simulator_core.simulation.mappers.mappers import EsdlMapperAbstract | ||
|
|
||
|
|
||
| class EsdlAssetHeatBufferMapper(EsdlMapperAbstract): | ||
| """Class to map an ESDL asset to a HeatBuffer entity class.""" | ||
|
|
||
| def to_esdl(self, entity: HeatBuffer) -> EsdlAssetObject: | ||
| """Map a HeatBuffer entity to an EsdlAsset.""" | ||
| raise NotImplementedError("EsdlAssetHeatBufferMapper.to_esdl()") | ||
|
|
||
| def to_entity(self, esdl_asset: EsdlAssetObject) -> AssetAbstract: | ||
| """Method to map an ESDL asset to a HeatBuffer entity class. | ||
|
|
||
| :param EsdlAssetObject esdl_asset: Object to be converted to a HeatBuffer entity. | ||
| :return: Ates object. | ||
| """ | ||
| heat_buffer_entity = HeatBuffer( | ||
| asset_name=esdl_asset.esdl_asset.name, | ||
| asset_id=esdl_asset.esdl_asset.id, | ||
| port_ids=esdl_asset.get_port_ids(), | ||
| volume=esdl_asset.get_property( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You won't need to call the EsdlAssetObject.get_property()[0] with the zero at the end; the method returns a float so it should work without. |
||
| esdl_property_name="volume", default_value=HEAT_BUFFER_DEFAULTS.volume | ||
| ), | ||
| ) | ||
|
|
||
| return heat_buffer_entity | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ def __init__( | |
| self.temperature_out = temperature_out | ||
| self.profile: pd.DataFrame = profile | ||
| self.start_index = 0 | ||
|
|
||
| # Theoretical maximum charge and discharge power of the storage. | ||
| self.max_charge_power: float = max_charge_power | ||
| self.max_discharge_power: float = max_discharge_power | ||
|
|
||
|
|
@@ -58,21 +60,28 @@ def get_heat_power(self, time: datetime.datetime) -> float: | |
| :param datetime.datetime time: Time for which to get the heat demand. | ||
| :return: float with the heat demand. | ||
| """ | ||
| # Check if the selected time is in the profile. | ||
| # TODO: Current implementation loops over the entire profile; should be improved! | ||
| # TODO: Unclear why there is a timestep of 1 hour in the profile. | ||
| for index in range(self.start_index, len(self.profile)): | ||
| if abs((self.profile["date"][index].to_pydatetime() - time).total_seconds()) < 3600: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not work as expected; what is the intention? Maybe we should make an seperate issue to review this part. |
||
| self.start_index = index | ||
| if self.profile["values"][index] > self.max_charge_power: | ||
| logging.warning( | ||
| f"Storage of {self.name} is higher than maximum charge power of asset" | ||
| f" at time {time}." | ||
| "Storage of %s is higher than maximum charge power of asset at time %s.", | ||
| self.name, | ||
| time, | ||
| ) | ||
| return self.max_charge_power | ||
| elif self.profile["values"][index] < self.max_discharge_power: | ||
| logging.warning( | ||
| f"Storage of {self.name} is higher than maximum discharge power of asset" | ||
| f" at time {time}." | ||
| "Storage of %s is higher than maximum discharge power of asset at time %s.", | ||
| self.name, | ||
| time, | ||
| ) | ||
| return self.max_discharge_power | ||
| else: | ||
| return float(self.profile["values"][index]) | ||
| return 0 | ||
| # TODO: The loop is not complete as the asset also has a fill-level that should not | ||
| # surpass the maximum fill-level. | ||
|
Comment on lines
+85
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is an implementation I made that can be merged/changed after we have completed the current PR. |
||
| return 0.0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you either remove this statement or explain why it is needed to also run flake8 on the unit test separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the linux script also include unit test, so i just want to make sure it is similar