Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jan 16, 2022
2 parents 1ab9377 + 51ff17f commit b8a0dd7
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 77 deletions.
78 changes: 53 additions & 25 deletions docs/analyses/exergy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ processes yet, chemical exergy is not considered. Changes in kinetic and
potential exergy are neglected and therefore not considered as well.

.. list-table:: Terminology

:widths: 20 20 10 50
:header-rows: 1
:class: tight-table
Expand Down Expand Up @@ -103,33 +104,35 @@ potential exergy are neglected and therefore not considered as well.

Tutorial
--------
In this short tutorial, an exergy analysis is carried out for the Solar Energy
Generating System (SEGS). The full python script is available on GitHub in
an individual repository: https://github.com/fwitte/SEGS_exergy.
In this short tutorial, an exergy analysis is carried out for the so called
"Solar Energy Generating System" (SEGS). The full python script is available on
GitHub in an individual repository: https://github.com/fwitte/SEGS_exergy.

Two other full code examples are to be found at:

- Supercritical CO\ :sub:`2` power cycle: https://github.com/fwitte/sCO2_exergy
- Refrigeration machine: https://github.com/fwitte/refrigeration_cycle_exergy

The SEGS consists of three main systems, the solar field, the steam cycle and
the cooling water system. In the solar field Therminol VP1 is used as heat
transfer liquid. In the steam generator and reheater the TVP1 is cooled down to
evaporate and overheat/reheat the water of the steam cycle. The turbine is
divided in a high pressure turbine and a low pressure turbine, which are
further subdivided in 2 stages (high pressure turbine) and 5 stages. In between
the stages steam is exctracted for preheating. Finally, the main condenser of
the steam cycle is connected to an air cooling tower. The figure below shows
the topology of the model.
SEGS consists of three main systems, the solar field, the steam cycle and the
cooling water system. In the solar field Therminol VP1 is used as heat transfer
fluid. In the steam generator and reheater the TVP1 is cooled down to evaporate
and overheat/reheat the water of the steam cycle. The turbine is divided in a
high pressure turbine and a low pressure turbine, which are further subdivided
in 2 parts (high pressure turbine) and 5 parts. In between the stages steam is
exctracted for preheating. Finally, the main condenser of the steam cycle is
connected to an air cooling tower. The figure below shows the topology of the
model.

.. figure:: api/_images/SEGS_flowsheet.svg

:align: center
:alt: Topology of the Solar Energy Generating System (SEGS)

The input data are based on literature :cite:`Kearney1988`, which provides
measured data. Some parameters are however taken from a follow-up publication,
as the original data show some inconsistencies, e.g. higher enthalpy at the low
pressure turbine's last stage outlet than at its inlet :cite:`Lippke1995`.
pressure turbine's last stage outlet than at its inlet :cite:`Lippke1995`. As
mentioned, you can find all data in the respective GitHub repository.

TESPy model
^^^^^^^^^^^
Expand All @@ -142,9 +145,11 @@ is implemented, calculating the surface area required for the provision of the
heat input at optimal conditions.

All components are flagged with the :code:`fkt_group` parameter, which will
automatically create component groups for the exergy analysis sankey diagram.
The specification of this parameter is not required for the exergy analysis
itself, but helps to simplify the automatically generated sankey diagram.
automatically create functional groups (component groups) for the exergy
analysis Grassmann diagram. The specification of this parameter is not required
for the exergy analysis itself, but helps to simplify the automatically
generated diagram. Components not assigned to any functional group will form
their respective group.

Regarding parameter specification, the following parameters are specified:

Expand Down Expand Up @@ -297,13 +302,14 @@ rounding errors).

Printing the results is possible with the
:py:meth:`tespy.tools.analyses.ExergyAnalysis.print_results` method. The
results are printed in five individual tables:
results are printed in six individual tables:

- connections
- components
- busses
- groups (component groups)
- aggregation (aggregation of components and the respective busses)
- network
- groups (functional groups)

By default, all of these tables are printed to the prompt. It is possible to
deselect the tables, e.g. by passing :code:`groups=False` to the method call.
Expand All @@ -312,9 +318,28 @@ deselect the tables, e.g. by passing :code:`groups=False` to the method call.
ean.print_results(groups=False, connections=False)
For the component related tables, i.e. busses, components and groups, the data
are sorted descending regarding the exergy destruction value of the individual
component.
For the component related tables, i.e. busses, components, aggregation and
groups, the data are sorted descending regarding the exergy destruction value
of the individual entry. The component data contain fuel exergy, product exergy
and exergy destruction values related to the component itself ignoring losses
that might occur on the busses, for example, mechanical or electrical
conversion losses in motors and generators. The bus data contain the respective
information related to the conversion losses on the busses only. The
aggregation data contain both, the component and the bus data. For instance,
a turbine driving a generator will have the electrical energy delivered by the
generator as product exergy value. The same component's exergy product without
considering the mechanical or electrical conversion losses is the shaft power
delivered by the turbine. From the generator's perspective, this is the fuel
exergy, while the product is the electrical energy.

.. note::

Please note, that in contrast to the component and bus data, group data do
not contain fuel and product exergy as well as exergy efficiency. Instead all
exergy streams entering the system borders of the component group and all
exergy streams leaving the system borders are calculated. On this basis, a
graphical representation of the exergy flows in the network can be generated
in the form of a Grassmann diagram.

Accessing the data
^^^^^^^^^^^^^^^^^^
Expand All @@ -328,6 +353,7 @@ the following code snippet.
connection_data = ean.connection_data
bus_data = ean.bus_data
component_data = ean.component_data
aggregation_data = ean.aggregation_data
network_data = ean.network_data
group_data = ean.group_data
Expand Down Expand Up @@ -356,6 +382,7 @@ diagram is then easily done:
fig.show()
.. figure:: api/_images/SEGS_sankey.png

:align: center
:alt: Sankey diagram of the Soler Energy Generating System (SEGS)

Expand Down Expand Up @@ -383,11 +410,12 @@ colors can be assigned to these types of streams.

.. note::

- The :code:`node_order` must contain all exergy streams, thus including
- The :code:`node_order` must contain all exergy streams, thus

- ALL component group labels
- lables of the busses used in the definitions of the analysis
- :code:`'E_F'`, :code:`'E_P'`, :code:`'E_D'`, :code:`'E_L'`
- ALL component group labels (you can find the labels in the group data
results printout),
- lables of the busses used in the definitions of the analysis and
- :code:`'E_F'`, :code:`'E_P'`, :code:`'E_D'` as well as :code:`'E_L'`

- The colors dictionary works with the following keys:

Expand Down
1 change: 1 addition & 0 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Discover noteable new features and improvements in each release
:local:
:backlinks: top

.. include:: whats_new/v0-5-1.rst
.. include:: whats_new/v0-5-0.rst
.. include:: whats_new/v0-4-4.rst
.. include:: whats_new/v0-4-3-003.rst
Expand Down
25 changes: 25 additions & 0 deletions docs/whats_new/v0-5-1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
v0.5.1 - Exciting Exergy (January, 14, 2022)
++++++++++++++++++++++++++++++++++++++++++++

Documentation
#############
- Improvements on the description of the exergy analysis results data.
Additional dataframe added, that contains the aggregated component exergy
analysis results (component and respective bus exergy data)
(`PR #293 <https://github.com/oemof/tespy/pull/293>`_).

Bug Fixes
#########
- In the first offdesign calculation the connection parameter specifications
in the LaTeX report were still reported in design mode
(`PR #290 <https://github.com/oemof/tespy/pull/290>`_).
- Labels of string representations of numeric labels in components, connections
and busses have been misinterpreted as numeric values by the network_reader
(`PR #298 <https://github.com/oemof/tespy/pull/298>`_).

Other Changes
#############

Contributors
############
- Francesco Witte (`@fwitte <https://github.com/fwitte>`_)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def read(*names, **kwargs):

setup(
name='TESPy',
version='0.5.0',
version='0.5.1',
license='MIT',
description='Thermal Engineering Systems in Python (TESPy)',
long_description='%s' % (
Expand All @@ -34,7 +34,7 @@ def read(*names, **kwargs):
)
),
author='Francesco Witte',
author_email='francesco.witte@hs-flensburg.de',
author_email='francesco.witte@dlr.de',
url='https://github.com/oemof/tespy',
packages=find_packages('src'),
package_dir={'': 'src'},
Expand Down
2 changes: 1 addition & 1 deletion src/tespy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8

__version__ = '0.5.0 - Davis\' Domain'
__version__ = '0.5.1 - Exciting Exergy'

# tespy data and connections import
from . import connections # noqa: F401
Expand Down
46 changes: 26 additions & 20 deletions src/tespy/networks/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,13 @@ def set_fluid_back_ends(self, memorise_fluid_properties):

# set up results dataframe for connections
cols = (
['m', 'p', 'h', 'T', 'v', 'vol', 's', 'x', 'Td_bp'] + self.fluids)
['m', 'p', 'h', 'T', 'v', 'vol', 's', 'x', 'Td_bp']
+ self.fluids)
self.results['Connection'] = pd.DataFrame(
columns=cols, dtype='float64')
# include column for fluid balance in specs dataframe
self.specifications['Connection'] = pd.DataFrame(
columns=cols, dtype='bool')
columns=cols + ['balance'], dtype='bool')
self.specifications['Ref'] = pd.DataFrame(
columns=cols, dtype='bool')
self.specifications['lookup'] = {
Expand Down Expand Up @@ -816,6 +818,7 @@ def init_set_properties(self):
"""Specification of SI values for user set values."""
# fluid property values
for c in self.conns['object']:
# set all specifications to False
self.specifications['Connection'].loc[c.label] = False
if not self.init_previous:
c.good_starting_values = False
Expand All @@ -830,11 +833,9 @@ def init_set_properties(self):
c.get_attr(key).unit = self.get_attr(key + '_unit')
# set SI value
if c.get_attr(key).val_set:
self.specifications['Connection'].loc[c.label, key] = True
c.get_attr(key).val_SI = hlp.convert_to_SI(
key, c.get_attr(key).val, c.get_attr(key).unit)
if c.get_attr(key).ref_set:
self.specifications['Ref'].loc[c.label, key] = True
if key == 'T':
c.get_attr(key).ref.delta_SI = hlp.convert_to_SI(
'Td_bp', c.get_attr(key).ref.delta,
Expand All @@ -854,16 +855,6 @@ def init_set_properties(self):
raise hlp.TESPyNetworkError(msg)
tmp0 = c.fluid.val0
tmp_set = c.fluid.val_set
self.specifications['Connection'].loc[
c.label, 'balance'] = c.fluid.balance

# enter fluid specifications into specification DataFrame
for fluid in self.fluids:
try:
self.specifications['Connection'].loc[c.label, fluid] = (
c.fluid.val_set[fluid])
except KeyError:
pass

c.fluid.val = OrderedDict()
c.fluid.val0 = OrderedDict()
Expand Down Expand Up @@ -1409,13 +1400,28 @@ def init_count_connections_parameters(self, c):
c : tespy.connections.connection.Connection
Connection count parameters of.
"""
self.num_conn_eq += [
c.m.val_set, c.p.val_set, c.h.val_set, c.T.val_set,
c.x.val_set, c.v.val_set, c.Td_bp.val_set].count(True)
self.num_conn_eq += [
c.m.ref_set, c.p.ref_set, c.h.ref_set, c.T.ref_set].count(True)
self.num_conn_eq += list(c.fluid.val_set.values()).count(True)
# variables 0 to 9: fluid properties
vars = self.specifications['Connection'].columns[:9]
row = [c.get_attr(var).val_set for var in vars]
self.num_conn_eq += row.count(True)
# write information to specifaction dataframe
self.specifications['Connection'].loc[c.label, vars] = row

row = [c.get_attr(var).ref_set for var in vars]
self.num_conn_eq += row.count(True)
# write refrenced value information to specifaction dataframe
self.specifications['Ref'].loc[c.label, vars] = row

# variables 9 to last but one: fluid mass fractions
fluids = self.specifications['Connection'].columns[9:-1]
row = [c.fluid.val_set[fluid] for fluid in fluids]
self.num_conn_eq += row.count(True)
self.specifications['Connection'].loc[c.label, fluids] = row

# last one: fluid balance specification
self.num_conn_eq += c.fluid.balance * 1
self.specifications['Connection'].loc[
c.label, 'balance'] = c.fluid.balance

def init_precalc_properties(self, c):
"""
Expand Down
21 changes: 12 additions & 9 deletions src/tespy/networks/network_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def load_network(path):

# create components
df['instance'] = df.apply(
construct_comps, axis=1, args=(char_lines, char_maps))
construct_components, axis=1, args=(char_lines, char_maps))

cols = [
'instance', 'label', 'busses', 'bus_param', 'bus_P_ref',
Expand Down Expand Up @@ -335,7 +335,8 @@ def load_network(path):
logging.debug(msg)

# create connections
conns['instance'] = conns.apply(construct_conns, axis=1, args=(comps, nw,))
conns['instance'] = conns.apply(
construct_connections, axis=1, args=(comps, nw,))
conns.apply(conns_set_ref, axis=1, args=(conns,))
conns = conns.set_index('id')

Expand Down Expand Up @@ -383,7 +384,7 @@ def load_network(path):
# %% create components


def construct_comps(c, *args):
def construct_components(c, *args):
r"""
Create TESPy component from class name and set parameters.
Expand All @@ -404,7 +405,7 @@ def construct_comps(c, *args):
TESPy component object.
"""
target_class = comp_target_classes[c['comp_type']]
instance = target_class(c['label'])
instance = target_class(str(c['label']))
kwargs = {}

# basic properties
Expand Down Expand Up @@ -521,7 +522,7 @@ def construct_network(path):
# %% create connections


def construct_conns(c, *args):
def construct_connections(c, *args):
r"""
Create TESPy connection from data in the .csv-file and its parameters.
Expand All @@ -539,12 +540,14 @@ def construct_conns(c, *args):
TESPy connection object.
"""
# create connection
conn = Connection(args[0].instance[c.source], c.source_id,
args[0].instance[c.target], c.target_id)
conn = Connection(
args[0].instance[c.source], c.source_id,
args[0].instance[c.target], c.target_id, label=str(c.label)
)

# read basic properties
for key in ['design', 'offdesign', 'design_path', 'local_design',
'local_offdesign', 'label']:
'local_offdesign']:
if key in c:
if isinstance(c[key], float):
setattr(conn, key, None)
Expand Down Expand Up @@ -625,7 +628,7 @@ def construct_busses(c, *args):
TESPy bus object.
"""
# set up bus with label and specify value for power
b = Bus(c.label, P=c.P)
b = Bus(str(c.label), P=c.P)
b.P.is_set = c.P_set
return b

Expand Down
Loading

0 comments on commit b8a0dd7

Please sign in to comment.