Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions docs/advanced_tutorials/heat_exchangers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,17 @@
"```{math}\n",
"\\Delta \\theta_\\text{log} = \\frac{\\Delta T_{i} - \\Delta T_{i+1}}{\\ln \\frac{\\Delta T_{i}}{\\Delta T_{i+1}}}\\\\\n",
"\n",
"kA=\\frac{\\dot Q}{\\Delta \\theta_\\text{log}}\\\\\n",
"\n",
"UA_{i}=\\frac{\\dot Q_{i}}{\\Delta \\theta_{\\text{log,}i}}\\\\\n",
"\n",
"UA=\\sum UA_{i}\n",
"\n",
"```\n",
"\n",
"For the calculation of {math}`kA` the terminal temperature differences `ttd_u` and\n",
"`ttd_l` are considered as {math}`\\Delta T_0` and {math}`\\Delta T_1`. For the calculation\n",
"of {math}`UA`, the internal temperature differences {math}`\\Delta T_{i}` in each section\n",
"of the heat exchanger are employed."
"For the calculation of {math}`UA` in 0D variants the terminal temperature\n",
"differences `ttd_u` and `ttd_l` are considered as {math}`\\Delta T_0` and\n",
"{math}`\\Delta T_1`. For the calculation of {math}`UA` in 1D variants the\n",
"internal temperature differences {math}`\\Delta T_{i}` in each section of the\n",
"heat exchanger are employed."
]
},
{
Expand All @@ -165,8 +164,7 @@
"results.append({\n",
" \"model\": \"HeatExchanger\",\n",
" \"minimum pinch (K)\": f\"n/a ({hx_0d.ttd_min.val:.1f})\",\n",
" \"kA (kW/K)\": f\"{hx_0d.kA.val:.1f}\",\n",
" \"UA (kW/K)\": \"n/a\",\n",
" \"UA (kW/K)\": f\"{hx_0d.UA.val:.1f}\",\n",
"})\n",
"\n",
"heat = [0, abs(hx_0d.Q.val)]\n",
Expand Down Expand Up @@ -232,8 +230,7 @@
"results.append({\n",
" \"model\": \"Condenser\",\n",
" \"minimum pinch (K)\": f\"n/a ({hx_cond.ttd_min.val:.1f})\",\n",
" \"kA (kW/K)\": f\"{hx_cond.kA.val:.1f}\",\n",
" \"UA (kW/K)\": \"n/a\",\n",
" \"UA (kW/K)\": f\"{hx_cond.UA.val:.1f}\",\n",
"})\n",
"\n",
"T_cond = c2.T.val_SI - c2.calc_td_dew()\n",
Expand Down Expand Up @@ -303,7 +300,6 @@
"results.append({\n",
" \"model\": \"MovingBoundaryHeatExchanger\",\n",
" \"minimum pinch (K)\": f\"{hx_mb.td_pinch.val:.2f}\",\n",
" \"kA (kW/K)\": f\"{hx_mb.kA.val:.1f}\",\n",
" \"UA (kW/K)\": f\"{hx_mb.UA.val:.1f}\",\n",
"})\n",
"\n",
Expand Down Expand Up @@ -369,7 +365,6 @@
"results.append({\n",
" \"model\": \"SectionedHeatExchanger (50 sections)\",\n",
" \"minimum pinch (K)\": f\"{hx_sectioned.td_pinch.val:.2f}\",\n",
" \"kA (kW/K)\": f\"{hx_sectioned.kA.val:.1f}\",\n",
" \"UA (kW/K)\": f\"{hx_sectioned.UA.val:.1f}\",\n",
"})\n",
"\n",
Expand Down Expand Up @@ -420,7 +415,6 @@
"results.append({\n",
" \"model\": \"SectionedHeatExchanger (6 sections)\",\n",
" \"minimum pinch (K)\": f\"{hx_sectioned.td_pinch.val:.2f}\",\n",
" \"kA (kW/K)\": f\"{hx_sectioned.kA.val:.1f}\",\n",
" \"UA (kW/K)\": f\"{hx_sectioned.UA.val:.1f}\",\n",
"})"
]
Expand Down
6 changes: 3 additions & 3 deletions docs/advanced_tutorials/heat_pump_steps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ The changes we want to apply can be summarized as follows:

- All heat exchangers should be calculated based on their heat transfer
coefficient with a characteristic for correction of that value depending
on the change of mass flow (:code:`kA_char` and :code:`UA_cecchinato` for the
on the change of mass flow (:code:`UA_char` and :code:`UA_cecchinato` for the
condenser). Therefore, pinch temperature difference and terminal temperature
difference value specifications need to be design parameters. Also, the
temperature at connection 14 cannot be specified anymore, since it will be a
Expand All @@ -451,8 +451,8 @@ The changes we want to apply can be summarized as follows:
isentropic efficiency instead of a constant value (:code:`eta_s_char`).
- Pressure drops in components will be a result of the changing mass flow
through that component given the diameter in the design. The pressure ratio
will therefore be replaced by :code:`zeta` for all heat exchangers. The zeta
value is a geometry independent value.
will therefore be replaced by :code:`zeta_d4` for all heat exchangers. The
zeta_d4 value is a geometry independent value (:math:`\zeta/D^4`).

On top of that, for the evaporator the characteristic function of the heat
transfer coefficient should follow different data than the default
Expand Down
4 changes: 2 additions & 2 deletions docs/basic_tutorials/district_heating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ In the second step we can fix the diameter to its resulting value and
therefore unset the desired pressure loss first. Then, we set the ambient
temperature of the pipes (we assume the temperature of the ambient is not
affected by the heat loss of the pipe). With the given heat loss, the
:code:`kA` value can be calculated. It is the area independent heat transfer
:code:`UA` value can be calculated. It is the area independent heat transfer
coefficient.

.. literalinclude:: /../tutorial/basics/district_heating.py
Expand All @@ -107,7 +107,7 @@ Next, we want to investigate what happens, in case the
- overall temperature level in the heating system is reduced.

To do that, we will use similar setups as show in the Rankine cycle
introduction. The :code:`kA` value of both pipes is assumed to be fixed, the
introduction. The :code:`UA` value of both pipes is assumed to be fixed, the
efficiency of the pump and pressure losses in consumer and heat source are
constant as well.

Expand Down
2 changes: 1 addition & 1 deletion docs/basic_tutorials/rankine_cycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ In order to apply these specifications, we can use the :code:`design` and
data in the list in an offdesign calculation. The keyword :code:`offdesign`
automatically sets the respective parameter for the offdesign calculation. In
case the specification refers to a value, the value is taken from the design
mode calculation. In the example, the main condenser's kA value is calculated
mode calculation. In the example, the main condenser's UA value is calculated
in the design simulation and its value will be kept constant through the
offdesign simulations.

Expand Down
62 changes: 31 additions & 31 deletions docs/building_blocks/components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ at the example of the heat transfer coefficient of an evaporator.
>>> he = HeatExchanger('evaporator')

>>> # specify the value
>>> he.set_attr(kA=1e5)
>>> he.kA.val
>>> he.set_attr(UA=1e5)
>>> he.UA.val
100000.0
>>> he.kA.is_set
>>> he.UA.is_set
True

>>> # possibilities to unset a value
>>> he.set_attr(kA=None)
>>> he.kA.is_set
>>> he.set_attr(UA=None)
>>> he.UA.is_set
False

Grouped parameters
Expand Down Expand Up @@ -186,8 +186,8 @@ is possible to specify your own data for these characteristic functions.
**There are two different characteristics specifications**

The characteristic function can be an auxiliary parameter of a different
component property. This is the case for :code:`kA_char1`
and :code:`kA_char2` of heat exchangers as well as the characteristics of a
component property. This is the case for :code:`UA_char1`
and :code:`UA_char2` of heat exchangers as well as the characteristics of a
combustion engine: :code:`tiP_char`, :code:`Q1_char`, :code:`Q2_char`
and :code:`Qloss_char`.

Expand All @@ -196,13 +196,13 @@ is possible to specify your own data for these characteristic functions.

**What does this mean?**

For the auxiliary functionality the main parameter, e.g. :code:`kA_char`
of a heat exchanger must be set :code:`.kA_char.is_set=True`.
For the auxiliary functionality the main parameter, e.g. :code:`UA_char`
of a heat exchanger must be set :code:`.UA_char.is_set=True`.

For the other functionality the characteristics parameter must be
set e.g. :code:`.eta_s_char.is_set=True`.

For example, :code:`kA_char` specification for heat exchangers:
For example, :code:`UA_char` specification for heat exchangers:

.. code-block:: python

Expand Down Expand Up @@ -235,49 +235,49 @@ For example, :code:`kA_char` specification for heat exchangers:

>>> nw.solve("design")
>>> nw.save("design_case.json")
>>> round(he.kA.val)
>>> round(he.UA.val)
503013

>>> # the characteristic function is made for offdesign calculation.
>>> he.set_attr(offdesign=["kA_char"])
>>> he.set_attr(offdesign=["UA_char"])
>>> c4.set_attr(design=["T"])
>>> nw.solve("offdesign", design_path="design_case.json")
>>> # since we did not change any property, the offdesign case yields the
>>> # same value as the design kA value
>>> round(he.kA.val)
>>> # same value as the design UA value
>>> round(he.UA.val)
503013

>>> c1.set_attr(m=9)
>>> # use a characteristic line from the defaults: specify the component, the
>>> # parameter and the name of the characteristic function. Also, specify,
>>> # what type of characteristic function you want to use.
>>> kA_char1 = ldc('HeatExchanger', 'kA_char1', 'DEFAULT', CharLine)
>>> kA_char2 = ldc('HeatExchanger', 'kA_char2', 'EVAPORATING FLUID', CharLine)
>>> he.set_attr(kA_char2=kA_char2)
>>> UA_char1 = ldc('HeatExchanger', 'UA_char1', 'DEFAULT', CharLine)
>>> UA_char2 = ldc('HeatExchanger', 'UA_char2', 'EVAPORATING FLUID', CharLine)
>>> he.set_attr(UA_char2=UA_char2)
>>> nw.solve("offdesign", design_path="design_case.json")
>>> round(he.kA.val)
>>> round(he.UA.val)
481745

>>> # specification of a data container yields the same result. It is
>>> # additionally possible to specify the characteristics parameter, e.g.
>>> # mass flow for kA_char1 (identical to default case) and volumetric
>>> # flow for kA_char2
>>> # mass flow for UA_char1 (identical to default case) and volumetric
>>> # flow for UA_char2
>>> he.set_attr(
... kA_char1={'char_func': kA_char1, 'param': 'm'},
... kA_char2={'char_func': kA_char2, 'param': 'v'}
... UA_char1={'char_func': UA_char1, 'param': 'm'},
... UA_char2={'char_func': UA_char2, 'param': 'v'}
... )
>>> nw.solve("offdesign", design_path="design_case.json")
>>> round(he.kA.val)
>>> round(he.UA.val)
481745

>>> # or use custom values for the characteristic line e.g. kA vs volumetric
>>> # or use custom values for the characteristic line e.g. UA vs volumetric
>>> # flow
>>> x = np.array([0, 0.5, 1, 2])
>>> y = np.array([0, 0.8, 1, 1.2])
>>> kA_char2 = CharLine(x, y)
>>> he.set_attr(kA_char2={'char_func': kA_char2, 'param': 'v'})
>>> UA_char2 = CharLine(x, y)
>>> he.set_attr(UA_char2={'char_func': UA_char2, 'param': 'v'})
>>> nw.solve("offdesign", design_path="design_case.json")
>>> round(he.kA.val)
>>> round(he.UA.val)
475107

Full working example for :code:`eta_s_char` specification of a turbine.
Expand Down Expand Up @@ -347,13 +347,13 @@ extrapolation parameter to :code:`True`.
# use custom specification parameters
>>> x = np.array([0, 0.5, 1, 2])
>>> y = np.array([0, 0.8, 1, 1.2])
>>> kA_char1 = CharLine(x, y, extrapolate=True)
>>> kA_char1.extrapolate
>>> UA_char1 = CharLine(x, y, extrapolate=True)
>>> UA_char1.extrapolate
True

>>> # set extrapolation to True for existing lines, e.g.
>>> he.kA_char1.char_func.extrapolate = True
>>> he.kA_char1.char_func.extrapolate
>>> he.UA_char1.char_func.extrapolate = True
>>> he.UA_char1.char_func.extrapolate
True

For more information on how the characteristic functions work
Expand Down
4 changes: 2 additions & 2 deletions docs/building_blocks/networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ The heat transfer coefficient is calculated in the preprocessing of the
offdesign case based on the results from the design-case. Of course, this
applies to all other parameters in the same way. Also, the pressure drop is a
result of the geometry for the offdesign case, thus we swap the pressure ratios
with zeta values.
with geometry independent zeta :math:`\frac{\zeta}{D^4}` values.

.. code-block:: python

mycomponent.set_attr(
design=['ttd_u', 'pr1', 'pr2'], offdesign=['kA', 'zeta1', 'zeta2']
design=['ttd_u', 'pr1', 'pr2'], offdesign=['UA', 'zeta1_d4', 'zeta2_d4']
)

.. note::
Expand Down
6 changes: 3 additions & 3 deletions docs/building_blocks/subsystems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,17 @@ different tespy classes required.
>>> # %% component parameters
>>> sg.get_comp('economizer').set_attr(
... pr1=0.999, pr2=0.97, design=['pr1', 'pr2'],
... offdesign=['zeta1', 'zeta2', 'kA_char']
... offdesign=['zeta1_d4', 'zeta2_d4', 'UA_char']
... )

>>> sg.get_comp('evaporator').set_attr(
... pr1=0.999, ttd_l=20, design=['pr1', 'ttd_l'],
... offdesign=['zeta1', 'kA_char']
... offdesign=['zeta1_d4', 'UA_char']
... )

>>> sg.get_comp('superheater').set_attr(
... pr1=0.999, pr2=0.99, design=['pr1', 'pr2'],
... offdesign=['zeta1', 'zeta2', 'kA_char']
... offdesign=['zeta1_d4', 'zeta2_d4', 'UA_char']
... )

>>> sg.get_conn('2').set_attr(td_bubble=5, design=['td_bubble'])
Expand Down
4 changes: 2 additions & 2 deletions docs/knowledge_center/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Modeling best practices
- discretized 1D models, which allow the specification of internal
pinch.

We have created an :ref:`overview <tutorial_heat_exchanger>` on the
different 0D and 1D types available and when to use which model.
We have created an :ref:`overview <tutorial_heat_exchanger_label>` on
the different 0D and 1D types available and when to use which model.

.. _faq_errors_label:

Expand Down
10 changes: 5 additions & 5 deletions docs/scripts/docstring_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@ def _ports_section(cls):
if kind == "fixed":
ports = entry.get("ports", [])
if ports:
lines.append(f"{label}: {', '.join(ports)}")
lines.append(f"- {label}: {', '.join(ports)}")
elif kind == "variable":
param = entry["parameter"]
pattern = entry["pattern"]
lines.append(
f"{label}: {pattern.replace('{n}', '1')}, "
f"- {label}: {pattern.replace('{n}', '1')}, "
f"{pattern.replace('{n}', '2')}, ... "
f"(variable, count set by :code:`{param}`)"
)
if not lines:
return ""
return "Ports\n-----\n\n" + "\n\n".join(lines)
return "Ports\n-----\n\n" + "\n".join(lines)


def _mandatory_section(instance):
Expand Down Expand Up @@ -266,8 +266,8 @@ def _parameters_section(instance, base_params=None, param_filter=None):
" " + " ".join(meta_parts) if meta_parts else ""
)
body_line = textwrap.fill(
desc_body.strip(), width=76, initial_indent=" ",
subsequent_indent=" "
desc_body.strip() or "Description missing.",
width=76, initial_indent=" ", subsequent_indent=" "
)
if ref:
eq_line = f" Equation: {ref}."
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/basics/cycle_closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class CycleCloser(Component):
Ports
-----
Fluid inlets: in1
Fluid outlets: out1
- Fluid inlets: in1
- Fluid outlets: out1
Mandatory Equations
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/tespy/components/basics/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Sink(Component):
Ports
-----
Fluid inlets: in1
- Fluid inlets: in1
Mandatory Equations
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/tespy/components/basics/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Source(Component):
Ports
-----
Fluid outlets: out1
- Fluid outlets: out1
Mandatory Equations
-------------------
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/basics/subsystem_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class SubsystemInterface(Component):
Ports
-----
Fluid inlets: in1, in2, ... (variable, count set by :code:`num_inter`)
Fluid outlets: out1, out2, ... (variable, count set by :code:`num_inter`)
- Fluid inlets: in1, in2, ... (variable, count set by :code:`num_inter`)
- Fluid outlets: out1, out2, ... (variable, count set by :code:`num_inter`)
Mandatory Equations
-------------------
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/combustion/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ class CombustionChamber(Component):
Ports
-----
Fluid inlets: in1, in2
Fluid outlets: out1
- Fluid inlets: in1, in2
- Fluid outlets: out1
Mandatory Equations
-------------------
Expand Down
5 changes: 2 additions & 3 deletions src/tespy/components/combustion/diabatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class DiabaticCombustionChamber(CombustionChamber):
Ports
-----

Fluid inlets: in1, in2

Fluid outlets: out1
- Fluid inlets: in1, in2
- Fluid outlets: out1

Mandatory Equations
-------------------
Expand Down
Loading
Loading