Skip to content

Commit

Permalink
Powercycle layout base (#2873)
Browse files Browse the repository at this point in the history
* 👥 Add Tiago to Contributing

* fix powercycle git branch again

* remove imported classes "imported_" names

* Relocate base utilities, test files as lowercase

* add PowerCycle tools file and associated pytest

* start of 'base' file commit

* apply tools test review comments

* apply review comments to `base` file

* new module error class and completed 'base' test

* make pytest for PowerData in new `net` file

* completed 'PowerData' pytest

* start pytests for PowerLoad class

* add pytest of sanity method for PowerLoad class

* add pytest for power load `add` method

* add debug message to `add` pytest of power load

* add pytest of `_validate_time` power load method

* add pytest for '_single_curve' power load method

* add docstrings to error classes and fix typos

* add `curve` test and reorder `PowerLoad` pytests

* add `_refine_vector` pytest for `PowerLoad` class

* move text plotting to ABC and add `plot` pytest

* add `__add__` pytest for PowerLoad class

* start implementing pytests for 'time' file

* add debug messages to 'time' pytests

* start 'PowerCyclePulse' implementation and tests

* complete `PowerCyclePulse` class and its pytest

* add `PowerCycleTimeline` class and its pytests

* organize powercycle module legacy files

* github comments implemented

* fix syntax

* fix interpolation test

* fix docstrings and implement BOPPhase class

* refactor & reorganize powercycle files and tests

* implement PulseLoad class

* fix net submodule file names

* fix net submodule file names

* add time normalization methods to load classes

* fix powerload test by removing caching

* add plot method to PhaseLoad class

* implement plot method for PhaseLoad class

* fix 'net_manager' file name

* refactor methods in `net_loads` classes

* rename `set` attributes to increase clarity

* implement 'PulseLoad .curve' + improvements

* add norm & shift, intrinsic times and testing kits

* turn times and sets into 'property' attributes

* fix 'curve' & plot phase delimiters in PulseLoad

* complete missing tests and revise docstrings

* prepare files for 'net_manager' classes

* rename PowerData as LoadData

* start manager implementation

* implement ScenarioBuilder class

* relocate ScenarioBuilder

* begin ScenarioBuilder tests implementation

* add test_validate_subdict

* add test_validate_dict

* add test_import_duration

* fix parametrize

* complete TestScenarioBuilder

* fix test_constructor

* relocate dictionary validation functions to tools

* add PowerCycleSystem up to parameter 'scenario'

* make PowerCycleSystem load lists into properties

* add the label attribute to PowerCycleABC class

* enable system phaseloads with new 'time' methods

* add PowerCycleManager and PowerCycleGroup

* add tests for PowerCycleGroup

* fix error in TestPowerCycleGroup

* add method to build pulse loads in manager

* implement __add__ for PhaseLoad

* add 'null' methods to loads to fix bug in manager

* fix bug in new PulseLoad phaseload_set validation

* fix wrong 'loads_MAG' input

* fix PowerCycleGroup method name

* PowerCycleABC.__eq__ and explicit consumption defs

* fix bug in PulseLoad.__add__

* fix bug and add plot method in manager

* fix 'raise' bugs identified by SonarCloud

* docstrings corrections caught by 'build-and-test'

* clean branch of future-development files

* correct capital in test variable

* rename `PowerLoadModel`, fix docstrings

* Add a simple power cycle example as introduction

* add docstrings in `simple.ex.py`

* text & code fixes in last `simple.ex.py` section

* check repository SSH connection

* Implement je-cook changes to `tools`

* Implement je-cook changes to `base`

* Implement je-cook changes to `time`

* Implement je-cook changes to `loads`

* Implement je-cook changes to `manager`

* implemented 'FormattedDict' class

* implemented 'FormattedLibrary' class

* modify `FormattedLibrary` to accept type as format

* substituted dicts by Formatted classes in `time`

* applied Formatted classes in `manager`,`importers`

* commented dict functions in `tools` to erase

* erase commented functions

* split FormattedLibrary into same class & Library

* implement more je-cook comments

* split 'simple' into scenario and manager examples

* rename 'import_kits' file

* prepare EUDEMO17 example

* add HCD and MAG to EUDEMO17 example

* add TFV loads to EUDEMO17 example

* add PDC loads to EUDEMO17 example

* add MNT loads to EUDEMO17 exmaple

* add CRY & AUX loads to EUDEMO17 example

* add BOP loads to EUDEMO17 example

* re-factor some example functions & branch cleaning

* split eudemo17 example in SSEN and complete cases

* clean branch

* add extra message about input file differentation

* 🎨 Prettier and formatting

* 🔥 Error cleanup

* 🔥 Remove string->array converter

* ♻️ First runthrough cleanup

* 🚧 WIP replace libraries with dataclasses

* 🔥 Remove old tests

* ♻️ Base cleanup

* 🔥 Remove FormattedDict

* ♻️ Use np.array

* ♻️ Improve data structure

* ♻️ General cleanup

* 🐛 Fix some tests and remove some tests

* ✅ Fix some tests

* 🐛 Removed too much

* 🎨 Base class

* 🎨 Cleanup

* 🔥 Remove and fix

* 🐛 Fix most tests and a bug or two

* 🐛 Fix last test

* 🎨 Descriptors on dataclasses

* 🎨 More cleanup

* 🔥 Remove str arrays

* 📝 Correct normalise spelling

* 🚚 Plot_obj -> _plot_load

* 🎨 Add kwarg warning

* 🏷️ Fix descriptor typing

* 🎨 Breakdown -> PowerCycleBreakdown

* 🎨 Sonarcloud codeqa

* 🐛 Fix examples

* 🐛 Fix imports in tests

* 🚧 Run through 2

* 🚧 Rearange and errors

* 🚧 Pulsesystemload

* 🚧 Slight rearrage, move plotting away from config

* 🚧 Add scenario as user interface

* 🚧 More rearrangement

* 🚧 More rearrangement

* 🔥 Remove some unneeded tests

* 🎨 PowerCyclePhase

* 🚧 WIP refactor 3

* ✨ Working refactor3

* ✅ Tests

* 🚨 Copyright notice

* 🔥 Remove unmodified files and plotting temporary things

* 🚨 Ruff fixes

* 🚸 Fix example header

* 🎨 Reorganise temporal link definition

* 🎨 Breakdown -> subphase

* 🚨 Fix linter

* 🎨 New config layout

* 🎨 Config read in fix for new layout

* 🎨 Fixed up code for new config layout

* 🐛 Fix tests

* 🎨 Str concat

* 🏷️ Small cleanup

* 🎨 First runthrough of suggestions

* 🎨 Durations changes

* 🎨 Remove classes in config

* 🎨 Remove powercycle prefix

* 🐛 Add from json fix

* 🎨 Always validate durations

* ✨ First runthrough of requested changes

* 🐛 Fix normalised interpolation bug

* 🐛 Fix consumption bug

* 🐛 End time is None catch

* 🎨 Make loads private variable of loadset

* ✅ Make tests work

* 📝 Reactive load comment

* 🎨 Simplify time specification for user

* ✅ Some more tests

* ✅ Duplicate test

* 🎨 Fix last suggestions

---------

Co-authored-by: Tiago Pomella Lobo <[email protected]>
  • Loading branch information
je-cook and tplobo committed Feb 5, 2024
1 parent ab1878e commit e929c15
Show file tree
Hide file tree
Showing 12 changed files with 2,111 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ authors:
given-names: S.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom

- family-names: Pomella Lobo
given-names: T.
affiliation: Karlsruher Institut f&uuml;r Technologie, Hermann-von-Helmholtz-Platz 1, 76344 Eggenstein-Leopoldshafen, Germany

- family-names: Saunders
given-names: H.
affiliation: United Kingdom Atomic Energy Authority, Culham Science Centre, Abingdon, Oxfordshire OX14 3DB, United Kingdom
Expand Down
2 changes: 2 additions & 0 deletions bluemira/base/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def __init__(self):
self.define("atomic_parts_per_million = appm = ppm")
# Other currencies need to be set up in a new context
self.define("USD = [currency]")
# EU directive volt-ampere reactive is lower case
self.define("var = VA")

self._gas_flow_temperature = None
self._contexts_added = False
Expand Down
8 changes: 5 additions & 3 deletions bluemira/base/reactor_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pprint
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Iterable, Tuple, Type, TypeVar, Union
from typing import Any, Dict, Iterable, Optional, Tuple, Type, TypeVar, Union

from bluemira.base.error import ReactorConfigError
from bluemira.base.look_and_feel import bluemira_debug, bluemira_warn
Expand Down Expand Up @@ -93,7 +93,7 @@ class GlobalParams(ParameterFrame):
def __init__(
self,
config_path: Union[str, Path, dict],
global_params_type: Type[_PfT],
global_params_type: Optional[Type[_PfT]] = None,
warn_on_duplicate_keys: bool = False,
warn_on_empty_local_params: bool = False,
warn_on_empty_config: bool = False,
Expand All @@ -108,7 +108,9 @@ def __init__(

self.config_data = config_data
self.global_params = make_parameter_frame(
self.config_data.get(_PARAMETERS_KEY, {}),
self.config_data.get(
_PARAMETERS_KEY, None if global_params_type is None else {}
),
global_params_type,
)

Expand Down
9 changes: 9 additions & 0 deletions bluemira/power_cycle/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2021-present M. Coleman, J. Cook, F. Franza
# SPDX-FileCopyrightText: 2021-present I.A. Maione, S. McIntosh
# SPDX-FileCopyrightText: 2021-present J. Morris, D. Short
#
# SPDX-License-Identifier: LGPL-2.1-or-later

"""
Power cycle module.
"""
25 changes: 25 additions & 0 deletions bluemira/power_cycle/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2021-present M. Coleman, J. Cook, F. Franza
# SPDX-FileCopyrightText: 2021-present I.A. Maione, S. McIntosh
# SPDX-FileCopyrightText: 2021-present J. Morris, D. Short
#
# SPDX-License-Identifier: LGPL-2.1-or-later

"""
Exception classes for the power cycle model.
"""

from bluemira.base.error import BluemiraError


class PowerCycleError(BluemiraError):
"""PowerCycle base error."""


class PowerLoadError(PowerCycleError):
"""PowerCycleLoad error class."""


class ScenarioLoadError(PowerCycleError):
"""
Exception class for 'ScenarioLoad' class of the Power Cycle module.
"""
Loading

0 comments on commit e929c15

Please sign in to comment.