Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Apr 30, 2024
2 parents 9ae6ee4 + dad4f80 commit c398407
Show file tree
Hide file tree
Showing 38 changed files with 165 additions and 111 deletions.
2 changes: 1 addition & 1 deletion docs/scripts/generate_tespy_data_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_char_data(filename):
path = resource_filename('tespy.data', filename + '.json')

with open(path) as f:
data = json.loads(f.read())
data = json.load(f)

return data

Expand Down
1 change: 1 addition & 0 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ What's New

Discover notable new features and improvements in each release

.. include:: whats_new/v0-7-4.rst
.. include:: whats_new/v0-7-3.rst
.. include:: whats_new/v0-7-2.rst
.. include:: whats_new/v0-7-1.rst
Expand Down
41 changes: 41 additions & 0 deletions docs/whats_new/v0-7-4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
v0.7.4 - Newton's Nature (April, 30, 2024)
++++++++++++++++++++++++++++++++++++++++++

Bug Fixes
#########
- :code:`Component` and :code:`FluidWrapper` objects are now available for the
:code:`load_network` function via the :code:`@component_registry` and
:code:`@wrapper_registry` decorators. E.g. if you are using custom components
you can decorate them with the :code:`@component_registry` and the load a
:code:`Network` with those components without needing to adjust the source
code of the :code:`load_network` function
(`PR #510 <https://github.com/oemof/tespy/pull/510>`__).

.. code-block:: python
>>> from tespy.components.component import component_registry
>>> from tespy.components import Source, Sink, SimpleHeatExchanger
>>> from tespy.connections import Connection
>>> from tespy.networks import Network, load_network
>>> @component_registry
... class MyComponent(SimpleHeatExchanger):
... pass
>>> c = component_registry.items["MyComponent"]("I am a component")
>>> c.label
'I am a component'
>>> nwk = Network()
>>> c1 = Connection(Source("source"), "out1", c, "in1", label="1")
>>> c2 = Connection(c, "out1", Sink("sink"), "in1", label="2")
>>> nwk.add_conns(c1, c2)
>>> nwk.export("exported_nwk")
>>> nwk = load_network("exported_nwk")
>>> nwk.comps.loc["I am a component", "comp_type"]
'MyComponent'
Contributors
############
- Francesco Witte (`@fwitte <https://github.com/fwitte>`__)
- `@jfreissmann <https://github.com/jfreissmann>`__
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exclude = ["docs/_build"]

[project]
name = "tespy"
version = "0.7.3"
version = "0.7.4"
description = "Thermal Engineering Systems in Python (TESPy)"
readme = "README.rst"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion src/tespy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

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

# tespy data and connections import
from . import connections # noqa: F401
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/components/basics/cycle_closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools.data_containers import ComponentProperties as dc_cp

# %%


@component_registry
class CycleCloser(Component):
r"""
Component for closing cycles.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/basics/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry


@component_registry
class Sink(Component):
r"""
A flow drains in a Sink.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/basics/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry


@component_registry
class Source(Component):
r"""
A flow originates from a Source.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/basics/subsystem_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"""

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools.data_containers import SimpleDataContainer as dc_simple


@component_registry
class SubsystemInterface(Component):
r"""
The subsystem interface does not change fluid properties.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/combustion/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools import logger
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.document_models import generate_latex_eq
Expand All @@ -27,6 +28,7 @@
from tespy.tools.helpers import fluidalias_in_list


@component_registry
class CombustionChamber(Component):
r"""
The class CombustionChamber is parent class of all combustion components.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/combustion/diabatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import numpy as np

from tespy.components import CombustionChamber
from tespy.components.component import component_registry
from tespy.tools import logger
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.document_models import generate_latex_eq
from tespy.tools.fluid_properties import h_mix_pT


@component_registry
class DiabaticCombustionChamber(CombustionChamber):
r"""
The class CombustionChamber is parent class of all combustion components.
Expand Down
4 changes: 3 additions & 1 deletion src/tespy/components/combustion/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.combustion.base import CombustionChamber
from tespy.components.component import component_registry
from tespy.tools import logger
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq
from tespy.tools.fluid_properties import h_mix_pT
from tespy.tools.fluid_properties import s_mix_ph
from tespy.tools.fluid_properties import s_mix_pT


@component_registry
class CombustionEngine(CombustionChamber):
r"""
An internal combustion engine supplies power and heat cogeneration.
Expand Down
9 changes: 9 additions & 0 deletions src/tespy/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
from tespy.tools.helpers import newton_with_kwargs


def component_registry(type):
component_registry.items[type.__name__] = type
return type


component_registry.items = {}


@component_registry
class Component:
r"""
Class Component is the base class of all TESPy components.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/heat_exchangers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.data_containers import GroupedComponentCharacteristics as dc_gcc
Expand All @@ -21,6 +22,7 @@
from tespy.tools.fluid_properties import s_mix_ph


@component_registry
class HeatExchanger(Component):
r"""
Class for counter current heat exchanger.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/heat_exchangers/condenser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import numpy as np

from tespy.components.component import component_registry
from tespy.components.heat_exchangers.base import HeatExchanger
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
from tespy.tools.data_containers import ComponentProperties as dc_cp
Expand All @@ -23,6 +24,7 @@
from tespy.tools.fluid_properties import h_mix_pQ


@component_registry
class Condenser(HeatExchanger):
r"""
A Condenser cools a fluid until it is in liquid state.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/heat_exchangers/desuperheater.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
SPDX-License-Identifier: MIT
"""

from tespy.components.component import component_registry
from tespy.components.heat_exchangers.base import HeatExchanger
from tespy.tools.document_models import generate_latex_eq
from tespy.tools.fluid_properties import dh_mix_dpQ
from tespy.tools.fluid_properties import h_mix_pQ


@component_registry
class Desuperheater(HeatExchanger):
r"""
The Desuperheater cools a fluid to the saturated gas state.
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/heat_exchangers/parabolic_trough.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.component import component_registry
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.data_containers import GroupedComponentProperties as dc_gcp
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq


@component_registry
class ParabolicTrough(SimpleHeatExchanger):
r"""
The ParabolicTrough calculates heat output from irradiance.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/heat_exchangers/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools import logger
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
from tespy.tools.data_containers import ComponentProperties as dc_cp
Expand All @@ -27,6 +28,7 @@
from tespy.tools.helpers import convert_to_SI


@component_registry
class SimpleHeatExchanger(Component):
r"""
A basic heat exchanger representing a heat source or heat sink.
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/heat_exchangers/solar_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.component import component_registry
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.data_containers import GroupedComponentProperties as dc_gcp
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq


@component_registry
class SolarCollector(SimpleHeatExchanger):
r"""
The solar collector calculates heat output from irradiance.
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/components/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools.document_models import generate_latex_eq


@component_registry
class NodeBase(Component):
"""Class NodeBase is parent class for all components of submodule nodes."""

Expand Down
3 changes: 3 additions & 0 deletions src/tespy/components/nodes/droplet_separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
SPDX-License-Identifier: MIT
"""

from tespy.components.component import component_registry
from tespy.components.nodes.base import NodeBase
from tespy.tools.document_models import generate_latex_eq
from tespy.tools.fluid_properties import dh_mix_dpQ
from tespy.tools.fluid_properties import h_mix_pQ


@component_registry
class DropletSeparator(NodeBase):
r"""
Separate liquid phase from gas phase of a single fluid.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/nodes/drum.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

import numpy as np

from tespy.components.component import component_registry
from tespy.components.nodes.droplet_separator import DropletSeparator
from tespy.tools.fluid_properties import h_mix_pQ


@component_registry
class Drum(DropletSeparator):
r"""
A drum separates saturated gas from saturated liquid.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/nodes/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

import numpy as np

from tespy.components.component import component_registry
from tespy.components.nodes.base import NodeBase
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq
from tespy.tools.fluid_properties import s_mix_pT


@component_registry
class Merge(NodeBase):
r"""
Class for merge points with multiple inflows and one outflow.
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/components/nodes/separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.component import component_registry
from tespy.components.nodes.base import NodeBase
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq
Expand All @@ -21,6 +20,7 @@
# from tespy.tools.fluid_properties import dT_mix_ph_dfluid


@component_registry
class Separator(NodeBase):
r"""
A separator separates fluid components from a mass flow.
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/components/nodes/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
SPDX-License-Identifier: MIT
"""

import numpy as np

from tespy.components.component import component_registry
from tespy.components.nodes.base import NodeBase
from tespy.tools.data_containers import SimpleDataContainer as dc_simple
from tespy.tools.document_models import generate_latex_eq


@component_registry
class Splitter(NodeBase):
r"""
Split up a mass flow in parts of identical enthalpy and fluid composition.
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/components/piping/pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
SPDX-License-Identifier: MIT
"""

from tespy.components.component import component_registry
from tespy.components.heat_exchangers.simple import SimpleHeatExchanger


@component_registry
class Pipe(SimpleHeatExchanger):
r"""
The Pipe is a subclass of a SimpleHeatExchanger.
Expand Down
Loading

0 comments on commit c398407

Please sign in to comment.