Skip to content

Commit c398407

Browse files
committed
Merge branch 'dev'
2 parents 9ae6ee4 + dad4f80 commit c398407

38 files changed

+165
-111
lines changed

docs/scripts/generate_tespy_data_module.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def get_char_data(filename):
1212
path = resource_filename('tespy.data', filename + '.json')
1313

1414
with open(path) as f:
15-
data = json.loads(f.read())
15+
data = json.load(f)
1616

1717
return data
1818

docs/whats_new.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ What's New
33

44
Discover notable new features and improvements in each release
55

6+
.. include:: whats_new/v0-7-4.rst
67
.. include:: whats_new/v0-7-3.rst
78
.. include:: whats_new/v0-7-2.rst
89
.. include:: whats_new/v0-7-1.rst

docs/whats_new/v0-7-4.rst

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
v0.7.4 - Newton's Nature (April, 30, 2024)
2+
++++++++++++++++++++++++++++++++++++++++++
3+
4+
Bug Fixes
5+
#########
6+
- :code:`Component` and :code:`FluidWrapper` objects are now available for the
7+
:code:`load_network` function via the :code:`@component_registry` and
8+
:code:`@wrapper_registry` decorators. E.g. if you are using custom components
9+
you can decorate them with the :code:`@component_registry` and the load a
10+
:code:`Network` with those components without needing to adjust the source
11+
code of the :code:`load_network` function
12+
(`PR #510 <https://github.com/oemof/tespy/pull/510>`__).
13+
14+
.. code-block:: python
15+
16+
>>> from tespy.components.component import component_registry
17+
>>> from tespy.components import Source, Sink, SimpleHeatExchanger
18+
>>> from tespy.connections import Connection
19+
>>> from tespy.networks import Network, load_network
20+
21+
>>> @component_registry
22+
... class MyComponent(SimpleHeatExchanger):
23+
... pass
24+
25+
>>> c = component_registry.items["MyComponent"]("I am a component")
26+
>>> c.label
27+
'I am a component'
28+
29+
>>> nwk = Network()
30+
>>> c1 = Connection(Source("source"), "out1", c, "in1", label="1")
31+
>>> c2 = Connection(c, "out1", Sink("sink"), "in1", label="2")
32+
>>> nwk.add_conns(c1, c2)
33+
>>> nwk.export("exported_nwk")
34+
>>> nwk = load_network("exported_nwk")
35+
>>> nwk.comps.loc["I am a component", "comp_type"]
36+
'MyComponent'
37+
38+
Contributors
39+
############
40+
- Francesco Witte (`@fwitte <https://github.com/fwitte>`__)
41+
- `@jfreissmann <https://github.com/jfreissmann>`__

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ exclude = ["docs/_build"]
2525

2626
[project]
2727
name = "tespy"
28-
version = "0.7.3"
28+
version = "0.7.4"
2929
description = "Thermal Engineering Systems in Python (TESPy)"
3030
readme = "README.rst"
3131
authors = [

src/tespy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
__datapath__ = os.path.join(importlib.resources.files("tespy"), "data")
6-
__version__ = '0.7.3 - Newton\'s Nature'
6+
__version__ = '0.7.4 - Newton\'s Nature'
77

88
# tespy data and connections import
99
from . import connections # noqa: F401

src/tespy/components/basics/cycle_closer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import numpy as np
1414

1515
from tespy.components.component import Component
16+
from tespy.components.component import component_registry
1617
from tespy.tools.data_containers import ComponentProperties as dc_cp
1718

18-
# %%
19-
2019

20+
@component_registry
2121
class CycleCloser(Component):
2222
r"""
2323
Component for closing cycles.

src/tespy/components/basics/sink.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import numpy as np
1414

1515
from tespy.components.component import Component
16+
from tespy.components.component import component_registry
1617

1718

19+
@component_registry
1820
class Sink(Component):
1921
r"""
2022
A flow drains in a Sink.

src/tespy/components/basics/source.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import numpy as np
1414

1515
from tespy.components.component import Component
16+
from tespy.components.component import component_registry
1617

1718

19+
@component_registry
1820
class Source(Component):
1921
r"""
2022
A flow originates from a Source.

src/tespy/components/basics/subsystem_interface.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
"""
1313

1414
from tespy.components.component import Component
15+
from tespy.components.component import component_registry
1516
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
1617

1718

19+
@component_registry
1820
class SubsystemInterface(Component):
1921
r"""
2022
The subsystem interface does not change fluid properties.

src/tespy/components/combustion/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import numpy as np
1717

1818
from tespy.components.component import Component
19+
from tespy.components.component import component_registry
1920
from tespy.tools import logger
2021
from tespy.tools.data_containers import ComponentProperties as dc_cp
2122
from tespy.tools.document_models import generate_latex_eq
@@ -27,6 +28,7 @@
2728
from tespy.tools.helpers import fluidalias_in_list
2829

2930

31+
@component_registry
3032
class CombustionChamber(Component):
3133
r"""
3234
The class CombustionChamber is parent class of all combustion components.

src/tespy/components/combustion/diabatic.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
import numpy as np
1515

1616
from tespy.components import CombustionChamber
17+
from tespy.components.component import component_registry
1718
from tespy.tools import logger
1819
from tespy.tools.data_containers import ComponentProperties as dc_cp
1920
from tespy.tools.document_models import generate_latex_eq
2021
from tespy.tools.fluid_properties import h_mix_pT
2122

2223

24+
@component_registry
2325
class DiabaticCombustionChamber(CombustionChamber):
2426
r"""
2527
The class CombustionChamber is parent class of all combustion components.

src/tespy/components/combustion/engine.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@
1010
1111
SPDX-License-Identifier: MIT
1212
"""
13+
1314
import numpy as np
1415

1516
from tespy.components.combustion.base import CombustionChamber
17+
from tespy.components.component import component_registry
1618
from tespy.tools import logger
1719
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
1820
from tespy.tools.data_containers import ComponentProperties as dc_cp
1921
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
2022
from tespy.tools.document_models import generate_latex_eq
21-
from tespy.tools.fluid_properties import h_mix_pT
2223
from tespy.tools.fluid_properties import s_mix_ph
2324
from tespy.tools.fluid_properties import s_mix_pT
2425

2526

27+
@component_registry
2628
class CombustionEngine(CombustionChamber):
2729
r"""
2830
An internal combustion engine supplies power and heat cogeneration.

src/tespy/components/component.py

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
from tespy.tools.helpers import newton_with_kwargs
3434

3535

36+
def component_registry(type):
37+
component_registry.items[type.__name__] = type
38+
return type
39+
40+
41+
component_registry.items = {}
42+
43+
44+
@component_registry
3645
class Component:
3746
r"""
3847
Class Component is the base class of all TESPy components.

src/tespy/components/heat_exchangers/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import numpy as np
1414

1515
from tespy.components.component import Component
16+
from tespy.components.component import component_registry
1617
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
1718
from tespy.tools.data_containers import ComponentProperties as dc_cp
1819
from tespy.tools.data_containers import GroupedComponentCharacteristics as dc_gcc
@@ -21,6 +22,7 @@
2122
from tespy.tools.fluid_properties import s_mix_ph
2223

2324

25+
@component_registry
2426
class HeatExchanger(Component):
2527
r"""
2628
Class for counter current heat exchanger.

src/tespy/components/heat_exchangers/condenser.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import numpy as np
1515

16+
from tespy.components.component import component_registry
1617
from tespy.components.heat_exchangers.base import HeatExchanger
1718
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
1819
from tespy.tools.data_containers import ComponentProperties as dc_cp
@@ -23,6 +24,7 @@
2324
from tespy.tools.fluid_properties import h_mix_pQ
2425

2526

27+
@component_registry
2628
class Condenser(HeatExchanger):
2729
r"""
2830
A Condenser cools a fluid until it is in liquid state.

src/tespy/components/heat_exchangers/desuperheater.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
SPDX-License-Identifier: MIT
1212
"""
1313

14+
from tespy.components.component import component_registry
1415
from tespy.components.heat_exchangers.base import HeatExchanger
1516
from tespy.tools.document_models import generate_latex_eq
1617
from tespy.tools.fluid_properties import dh_mix_dpQ
1718
from tespy.tools.fluid_properties import h_mix_pQ
1819

1920

21+
@component_registry
2022
class Desuperheater(HeatExchanger):
2123
r"""
2224
The Desuperheater cools a fluid to the saturated gas state.

src/tespy/components/heat_exchangers/parabolic_trough.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
SPDX-License-Identifier: MIT
1212
"""
1313

14-
import numpy as np
15-
14+
from tespy.components.component import component_registry
1615
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger
1716
from tespy.tools.data_containers import ComponentProperties as dc_cp
1817
from tespy.tools.data_containers import GroupedComponentProperties as dc_gcp
19-
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
2018
from tespy.tools.document_models import generate_latex_eq
2119

2220

21+
@component_registry
2322
class ParabolicTrough(SimpleHeatExchanger):
2423
r"""
2524
The ParabolicTrough calculates heat output from irradiance.

src/tespy/components/heat_exchangers/simple.py

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import numpy as np
1717

1818
from tespy.components.component import Component
19+
from tespy.components.component import component_registry
1920
from tespy.tools import logger
2021
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
2122
from tespy.tools.data_containers import ComponentProperties as dc_cp
@@ -27,6 +28,7 @@
2728
from tespy.tools.helpers import convert_to_SI
2829

2930

31+
@component_registry
3032
class SimpleHeatExchanger(Component):
3133
r"""
3234
A basic heat exchanger representing a heat source or heat sink.

src/tespy/components/heat_exchangers/solar_collector.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
SPDX-License-Identifier: MIT
1212
"""
1313

14-
import numpy as np
15-
14+
from tespy.components.component import component_registry
1615
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger
1716
from tespy.tools.data_containers import ComponentProperties as dc_cp
1817
from tespy.tools.data_containers import GroupedComponentProperties as dc_gcp
19-
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
2018
from tespy.tools.document_models import generate_latex_eq
2119

2220

21+
@component_registry
2322
class SolarCollector(SimpleHeatExchanger):
2423
r"""
2524
The solar collector calculates heat output from irradiance.

src/tespy/components/nodes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
SPDX-License-Identifier: MIT
1111
"""
1212

13-
import numpy as np
14-
1513
from tespy.components.component import Component
14+
from tespy.components.component import component_registry
1615
from tespy.tools.document_models import generate_latex_eq
1716

1817

18+
@component_registry
1919
class NodeBase(Component):
2020
"""Class NodeBase is parent class for all components of submodule nodes."""
2121

src/tespy/components/nodes/droplet_separator.py

+3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@
1010
1111
SPDX-License-Identifier: MIT
1212
"""
13+
14+
from tespy.components.component import component_registry
1315
from tespy.components.nodes.base import NodeBase
1416
from tespy.tools.document_models import generate_latex_eq
1517
from tespy.tools.fluid_properties import dh_mix_dpQ
1618
from tespy.tools.fluid_properties import h_mix_pQ
1719

1820

21+
@component_registry
1922
class DropletSeparator(NodeBase):
2023
r"""
2124
Separate liquid phase from gas phase of a single fluid.

src/tespy/components/nodes/drum.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
import numpy as np
1414

15+
from tespy.components.component import component_registry
1516
from tespy.components.nodes.droplet_separator import DropletSeparator
1617
from tespy.tools.fluid_properties import h_mix_pQ
1718

1819

20+
@component_registry
1921
class Drum(DropletSeparator):
2022
r"""
2123
A drum separates saturated gas from saturated liquid.

src/tespy/components/nodes/merge.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212

1313
import numpy as np
1414

15+
from tespy.components.component import component_registry
1516
from tespy.components.nodes.base import NodeBase
1617
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
1718
from tespy.tools.document_models import generate_latex_eq
1819
from tespy.tools.fluid_properties import s_mix_pT
1920

2021

22+
@component_registry
2123
class Merge(NodeBase):
2224
r"""
2325
Class for merge points with multiple inflows and one outflow.

src/tespy/components/nodes/separator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
SPDX-License-Identifier: MIT
1111
"""
1212

13-
import numpy as np
14-
13+
from tespy.components.component import component_registry
1514
from tespy.components.nodes.base import NodeBase
1615
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
1716
from tespy.tools.document_models import generate_latex_eq
@@ -21,6 +20,7 @@
2120
# from tespy.tools.fluid_properties import dT_mix_ph_dfluid
2221

2322

23+
@component_registry
2424
class Separator(NodeBase):
2525
r"""
2626
A separator separates fluid components from a mass flow.

src/tespy/components/nodes/splitter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
SPDX-License-Identifier: MIT
1111
"""
1212

13-
import numpy as np
14-
13+
from tespy.components.component import component_registry
1514
from tespy.components.nodes.base import NodeBase
1615
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
1716
from tespy.tools.document_models import generate_latex_eq
1817

1918

19+
@component_registry
2020
class Splitter(NodeBase):
2121
r"""
2222
Split up a mass flow in parts of identical enthalpy and fluid composition.

src/tespy/components/piping/pipe.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
SPDX-License-Identifier: MIT
1111
"""
1212

13+
from tespy.components.component import component_registry
1314
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger
1415

1516

17+
@component_registry
1618
class Pipe(SimpleHeatExchanger):
1719
r"""
1820
The Pipe is a subclass of a SimpleHeatExchanger.

0 commit comments

Comments
 (0)