tespy.components module#

tespy.components.component module#

Module class component.

All tespy components inherit from this class.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/components.py

SPDX-License-Identifier: MIT

class tespy.components.component.Component(label, **kwargs)[source]#

Bases: object

Class Component is the base class of all TESPy components.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • **kwargs – See the class documentation of desired component for available keywords.

Note

The initialisation method (__init__), setter method (set_attr) and getter method (get_attr) are used for instances of class component and its children.

Allowed keywords in kwargs are ‘design_path’, ‘design’ and ‘offdesign’. Additional keywords depend on the type of component you want to create.

Example

Basic example for a setting up a tespy.components.component.Component object. This example does not run a tespy calculation.

>>> from tespy.components.component import Component
>>> comp = Component('myComponent')
>>> type(comp)
<class 'tespy.components.component.Component'>
bus_func(bus)[source]#

Base method for calculation of the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

residual (float) – Residual value of bus equation.

calc_bus_efficiency(bus)[source]#

Return the busses’ efficiency.

Parameters:

bus (tespy.connections.bus.Bus) – Bus to calculate the efficiency value on.

Returns:

efficiency (float) – Efficiency value of the bus.

\[\begin{split}\eta_\mathrm{bus} = \begin{cases} \eta\left( \frac{\dot{E}_\mathrm{bus}}{\dot{E}_\mathrm{bus,ref}}\right) & \text{bus base = 'bus'}\\ \eta\left( \frac{\dot{E}_\mathrm{component}} {\dot{E}_\mathrm{component,ref}}\right) & \text{bus base = 'component'} \end{cases}\end{split}\]

Note

If the base value of the bus is the bus value itself, a newton iteration is used to find the bus value satisfying the corresponding equation (case 1).

calc_bus_expr(bus)[source]#

Return the busses’ characteristic line input expression.

Parameters:

bus (tespy.connections.bus.Bus) – Bus to calculate the characteristic function expression for.

Returns:

expr (float) – Ratio of power to power design depending on the bus base specification.

calc_bus_value(bus)[source]#

Return the busses’ value of the component’s energy transfer.

Parameters:

bus (tespy.connections.bus.Bus) – Bus to calculate energy transfer on.

Returns:

bus_value (float) – Value of the energy transfer on the specified bus.

\[\begin{split}\dot{E}_\mathrm{bus} = \begin{cases} \frac{\dot{E}_\mathrm{component}}{f\left( \frac{\dot{E}_\mathrm{bus}}{\dot{E}_\mathrm{bus,ref}}\right)} & \text{bus base = 'bus'}\\ \dot{E}_\mathrm{component} \cdot f\left( \frac{\dot{E}_\mathrm{component}} {\dot{E}_\mathrm{component,ref}}\right) & \text{bus base = 'component'} \end{cases}\end{split}\]

Note

If the base value of the bus is the bus value itself, a newton iteration is used to find the bus value satisfying the corresponding equation (case 1).

calc_parameters()[source]#

Postprocessing parameter calculation.

calc_zeta(i, o)[source]#
check_parameter_bounds()[source]#

Check parameter value limits.

convergence_check()[source]#
enthalpy_equality_deriv(k)[source]#

Calculate partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the mass flow balance equations.

enthalpy_equality_func()[source]#

Equation for enthalpy equality.

Returns:

residual (list) – Residual values of equations.

\[0 = h_{in,i} - h_{out,i} \;\forall i\in\text{inlets}\]

enthalpy_equality_func_doc(label)[source]#

Equation for enthalpy equality.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Entropy balance calculation method.

exergy_balance(T0)[source]#

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_attr(key)[source]#

Get the value of a component’s attribute.

Parameters:

key (str) – The attribute you want to retrieve.

Returns:

out – Value of specified attribute.

get_char_expr(param, type='rel', inconn=0, outconn=0)[source]#

Generic method to access characteristic function parameters.

Parameters:
  • param (str) – Parameter for characteristic function evaluation.

  • type (str) – Type of expression:

    • rel: relative to design value

    • abs: absolute value

  • inconn (int) – Index of inlet connection.

  • outconn (int) – Index of outlet connection.

Returns:

expr (float) – Value of expression

get_char_expr_doc(param, type='rel', inconn=0, outconn=0)[source]#

Generic method to access characteristic function parameters.

Parameters:
  • param (str) – Parameter for characteristic function evaluation.

  • type (str) – Type of expression:

    • rel: relative to design value

    • abs: absolute value

  • inconn (int) – Index of inlet connection.

  • outconn (int) – Index of outlet connection.

Returns:

expr (str) – LaTeX code for documentation

get_mandatory_constraints()[source]#
get_parameters()[source]#
get_plotting_data()[source]#
initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 0 & \text{key = 'p'}\\ 0 & \text{key = 'h'} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 0 & \text{key = 'p'}\\ 0 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static is_branch_source()[source]#
static is_variable(var, increment_filter=None)[source]#
numeric_deriv(func, dx, conn=None, **kwargs)[source]#

Calculate partial derivative of the function func to dx.

For details see tespy.tools.helpers._numeric_deriv()

static outlets()[source]#
pr_deriv(increment_filter, k, pr='', inconn=0, outconn=0)[source]#

Calculate residual value of pressure ratio function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

  • pr (str) – Component parameter to evaluate the pr_func on, e.g. pr1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

pr_func(pr='', inconn=0, outconn=0)[source]#

Calculate residual value of pressure ratio function.

Parameters:
  • pr (str) – Component parameter to evaluate the pr_func on, e.g. pr1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

Returns:

residual (float) – Residual value of function.

\[0 = p_{in} \cdot pr - p_{out}\]

pr_func_doc(label, pr='', inconn=0, outconn=0)[source]#

Calculate residual value of pressure ratio function.

Parameters:
  • pr (str) – Component parameter to evaluate the pr_func on, e.g. pr1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

Returns:

residual (float) – Residual value of function.

preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

pressure_equality_deriv(k)[source]#

Calculate partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the mass flow balance equations.

pressure_equality_func()[source]#

Equation for pressure equality.

Returns:

residual (float) – Residual value of equation.

\[0 = p_{in,i} - p_{out,i} \;\forall i\in\text{inlets}\]

pressure_equality_func_doc(label)[source]#

Equation for pressure equality.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
set_attr(**kwargs)[source]#

Set, reset or unset attributes of a component for provided arguments.

Parameters:
  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • **kwargs – See the class documentation of desired component for available keywords.

Note

Allowed keywords in kwargs are obtained from class documentation as all components share the tespy.components.component.Component.set_attr() method.

set_parameters(mode, data)[source]#

Set or unset design values of component parameters.

Parameters:
  • mode (str) – Setting component design values for mode='offdesign' and unsetting them for mode='design'.

  • df (pandas.core.series.Series) – Series containing the component parameters.

solve(increment_filter)[source]#

Solve equations and calculate partial derivatives of a component.

Parameters:

increment_filter (ndarray) – Matrix for filtering non-changing variables.

zeta_deriv(increment_filter, k, zeta='', inconn=0, outconn=0)[source]#

Calculate partial derivatives of zeta function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

  • zeta (str) – Component parameter to evaluate the zeta_func on, e.g. zeta1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

zeta_func(zeta='', inconn=0, outconn=0)[source]#

Calculate residual value of \(\zeta\)-function.

Parameters:
  • zeta (str) – Component parameter to evaluate the zeta_func on, e.g. zeta1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

Returns:

residual (float) – Residual value of function.

\[\begin{split}0 = \begin{cases} p_{in} - p_{out} & |\dot{m}| < \epsilon \\ \frac{\zeta}{D^4} - \frac{(p_{in} - p_{out}) \cdot \pi^2} {8 \cdot \dot{m}_{in} \cdot |\dot{m}_{in}| \cdot \frac{v_{in} + v_{out}}{2}} & |\dot{m}| > \epsilon \end{cases}\end{split}\]

Note

The zeta value is caluclated on the basis of a given pressure loss at a given flow rate in the design case. As the cross sectional area A will not change, it is possible to handle the equation in this way:

\[\frac{\zeta}{D^4} = \frac{\Delta p \cdot \pi^2} {8 \cdot \dot{m}^2 \cdot v}\]
zeta_func_doc(label, zeta='', inconn=0, outconn=0)[source]#

Calculate residual value of \(\zeta\)-function.

Parameters:
  • zeta (str) – Component parameter to evaluate the zeta_func on, e.g. zeta1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

Returns:

residual (float) – Residual value of function.

tespy.components.subsystem module#

Module for custom component groups.

It is possible to create subsystems of component groups in tespy. The subsystem class is the base class for custom subsystems.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/subsystems.py

SPDX-License-Identifier: MIT

class tespy.components.subsystem.Subsystem(label)[source]#

Bases: object

Class Subsystem is the base class of all TESPy subsystems.

Parameters:

label (str) – The label of the subsystem.

Example

Basic example for a setting up a Subsystem object. This example does not run a TESPy calculation!

>>> from tespy.components import Subsystem
>>> mysub = Subsystem('mySubsystem')
>>> type(mysub)
<class 'tespy.components.subsystem.Subsystem'>
>>> mysub.get_attr('label')
'mySubsystem'
create_comps()[source]#

Create the subsystem’s components.

create_conns()[source]#

Create the subsystem’s connections.

get_attr(key)[source]#

Get the value of a subsystem’s attribute.

Parameters:

key (str) – The attribute you want to retrieve.

Returns:

out – Value of specified attribute.

tespy.components.basics.cycle_closer module#

Module for class CycleCloser

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/basics/cycle_closer.py

SPDX-License-Identifier: MIT

class tespy.components.basics.cycle_closer.CycleCloser(label, **kwargs)[source]#

Bases: Component

Component for closing cycles.

Mandatory Equations

  • tespy.components.basics.cycle_closer.CycleCloser.pressure_equality_func()

  • tespy.components.basics.cycle_closer.CycleCloser.enthalpy_equality_func()

Image not available

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

Note

This component can be used to close a cycle process. The system of equations describing your plant will overdetermined, if you close a cycle without this component or a cut the cycle with a sink and a source at some point of the cycle. This component can be used instead of cutting the cycle.

Example

Create a cycle containing a pump and a pipe. The pump increases pressure the pipe cools the liquid and destroys the pressure rise. The heat extracted at the pipe must be the same value of the power input at the pump (but negative), as there is no other in- or outputs of energy in the system.

>>> from tespy.components import CycleCloser, Pipe, Pump
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> pi = Pipe('pipe')
>>> pu = Pump('pump')
>>> cc = CycleCloser('cycle closing component')
>>> cc.component()
'cycle closer'
>>> pu_pi = Connection(pu, 'out1', pi, 'in1')
>>> pi_cc = Connection(pi, 'out1', cc, 'in1')
>>> cc_pu = Connection(cc, 'out1', pu, 'in1')
>>> nw.add_conns(pu_pi, pi_cc, cc_pu)
>>> pi_cc.set_attr(p=1, T=20, fluid={'water': 1})
>>> pu_pi.set_attr(p=10)
>>> pu.set_attr(eta_s=0.8, P=1000)
>>> nw.solve('design')
>>> round(pi.Q.val, 1) == -round(pu.P.val, 1)
True
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
get_mandatory_constraints()[source]#
static get_parameters()[source]#
static inlets()[source]#
static is_branch_source()[source]#
static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
start_branch()[source]#
start_fluid_wrapper_branch()[source]#

tespy.components.basics.sink module#

Module for class Sink.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/basics/sink.py

SPDX-License-Identifier: MIT

class tespy.components.basics.sink.Sink(label, **kwargs)[source]#

Bases: Component

A flow drains in a Sink.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

Example

Create a sink and specify a label.

>>> from tespy.components import Sink
>>> si = Sink('a labeled sink')
>>> si.component()
'sink'
>>> si.label
'a labeled sink'
static component()[source]#
exergy_balance(T0)[source]#

Exergy balance calculation method of a sink.

A sink does not destroy or produce exergy. The value of \(\dot{E}_\mathrm{bus}\) is set to the exergy of the mass flow to make exergy balancing methods more simple as in general a mass flow can be fuel, product or loss.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[\dot{E}_\mathrm{bus} = \dot{E}_\mathrm{in}^\mathrm{PH}\]
static get_mandatory_constraints()[source]#
static inlets()[source]#
propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#

tespy.components.basics.source module#

Module for class Source.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/basics/source.py

SPDX-License-Identifier: MIT

class tespy.components.basics.source.Source(label, **kwargs)[source]#

Bases: Component

A flow originates from a Source.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

Example

Create a source and specify a label.

>>> from tespy.components import Source
>>> so = Source('a labeled source')
>>> so.component()
'source'
>>> so.label
'a labeled source'
static component()[source]#
exergy_balance(T0)[source]#

Exergy balance calculation method of a source.

A source does not destroy or produce exergy. The value of \(\dot{E}_\mathrm{bus}\) is set to the exergy of the mass flow to make exergy balancing methods more simple as in general a mass flow can be fuel, product or loss.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[\dot{E}_\mathrm{bus} = \dot{E}_\mathrm{out}^\mathrm{PH}\]
static get_mandatory_constraints()[source]#
static is_branch_source()[source]#
static outlets()[source]#
start_branch()[source]#
start_fluid_wrapper_branch()[source]#

tespy.components.basics.subsystem_interface module#

Module for class SubsystemInterface.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/basics/subsystem_interface.py

SPDX-License-Identifier: MIT

class tespy.components.basics.subsystem_interface.SubsystemInterface(label, **kwargs)[source]#

Bases: Component

The subsystem interface does not change fluid properties.

Mandatory Equations

Inlets/Outlets

  • Specify number of inlets and outlets with num_inter, predefined value: 1.

Image

flowsheet of the subsystem interfaceflowsheet of the subsystem interface
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • num_inter (float, dict) – Number of interfaces for subsystem.

Note

This component passes all fluid properties and mass flow from its inlet to the outlet.

Example

As connections can only connect a component with a different component, the subsystem interface is used to connect subsystems with the rest of your network. It is necessary to specify the number of interfaces of the subsystem interface, if you want any number other than 1. We will not go in depth of subsystem usage in this example. Please refer to this section for more information on building your own subsystems.

>>> from tespy.components import Sink, Source, SubsystemInterface
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> nw = Network()
>>> nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> so1 = Source('source 1')
>>> si1 = Sink('sink 1')
>>> so2 = Source('source 2')
>>> si2 = Sink('sink 2')
>>> IF = SubsystemInterface('subsystem interface', num_inter=2)
>>> IF.component()
'subsystem interface'
>>> len(IF.inlets())
2

The interface does not change the fluid properties in any way.

>>> inc1 = Connection(so1, 'out1', IF, 'in1')
>>> outg1 = Connection(IF, 'out1', si1, 'in1')
>>> inc2 = Connection(so2, 'out1', IF, 'in2')
>>> outg2 = Connection(IF, 'out2', si2, 'in1')
>>> nw.add_conns(inc1, outg1, inc2, outg2)
>>> inc1.set_attr(fluid={'H2O': 1}, T=40, p=3, m=100)
>>> inc2.set_attr(fluid={'N2': 1}, T=60, p=1, v=10)
>>> nw.solve('design')
>>> inc1.m.val_SI == outg1.m.val_SI
True
>>> inc2.m.val_SI == outg2.m.val_SI
True
>>> inc1.h.val_SI == outg1.h.val_SI
True
>>> inc2.h.val_SI == outg2.h.val_SI
True
static component()[source]#
get_mandatory_constraints()[source]#
static get_parameters()[source]#
inlets()[source]#
outlets()[source]#

tespy.components.combustion.base module#

Module of class CombustionChamber.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/base.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.base.CombustionChamber(label, **kwargs)[source]#

Bases: Component

The class CombustionChamber is parent class of all combustion components.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamberflowsheet of the combustion chamber

Note

The fuel and the air components can be connected to either of the inlets.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Actual oxygen to stoichiometric oxygen ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

Note

For more information on the usage of the combustion chamber see the examples section on github or look for the combustion chamber tutorials at tespy.readthedocs.io.

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel.

>>> from tespy.components import Sink, Source, CombustionChamber
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.fluid_properties import T_sat_p
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> amb = Source('ambient air')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> comb = CombustionChamber('combustion chamber')
>>> comb.component()
'combustion chamber'
>>> amb_comb = Connection(amb, 'out1', comb, 'in1')
>>> sf_comb = Connection(sf, 'out1', comb, 'in2')
>>> comb_fg = Connection(comb, 'out1', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)

Specify the thermal input of the combustion chamber. At the given fluid compositions this determines the mass flow of the fuel. The outlet temperature of the flue gas determines the ratio of oxygen to fuel mass flow.

>>> comb.set_attr(ti=500000, lamb=1.5)
>>> amb_comb.set_attr(p=1, T=20, fluid={'Ar': 0.0129, 'N2': 0.7553,
... 'CO2': 0.0004, 'O2': 0.2314})
>>> sf_comb.set_attr(T=25, fluid={'CO2': 0.03, 'H2': 0.01, 'CH4': 0.96})
>>> nw.solve('design')
>>> comb_fg.set_attr(T=1200)
>>> comb.set_attr(lamb=None)
>>> nw.solve('design')
>>> round(comb.lamb.val, 3)
2.014
>>> comb.set_attr(lamb=2)
>>> comb_fg.set_attr(T=None)
>>> nw.solve('design')
>>> round(comb_fg.T.val, 1)
1206.6
bus_deriv(bus)[source]#

Calculate the matrix of partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

val (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\dot{E} = LHV \cdot \dot{m}_{f}\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_lambda()[source]#

Calculate oxygen to stoichimetric oxygen ration

Returns:

lambda (float) – Oxygent to stoichiometric oxygen ratio.

\[ \begin{align}\begin{aligned}\lambda = \frac{\dot{m}_{f,m}}{\dot{m}_{O_2,m} \cdot \left(n_{C,fuel} + 0.25 \cdot n_{H,fuel}\right)}\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in inlets\end{split}\end{aligned}\end{align} \]

calc_lhv(f)[source]#

Calculate the lower heating value of the combustion chamber’s fuel.

  • Source for fluids O2, H2O and CO2: [17]

  • Source for all other fluids: [18]

Parameters:

f (str) – Alias of the fuel.

Returns:

val (float) – Lower heating value of the combustion chambers fuel.

\[\begin{split}LHV = -\frac{\sum_i {\Delta H_f^0}_i - \sum_j {\Delta H_f^0}_j } {M_{fuel}}\\ \forall i \in \text{reation products},\\ \forall j \in \text{reation educts},\\ \Delta H_f^0: \text{molar formation enthalpy}\end{split}\]

calc_parameters()[source]#

Postprocessing parameter calculation.

calc_ti()[source]#

Calculate the thermal input of the combustion chamber.

Returns:

ti (float) – Thermal input.

\[ti = LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{fuel,in,i} \right) - \dot{m}_{out,1} \cdot x_{fuel,out,1} \right] \; \forall i \in [1,2]\]

combustion_pressure_deriv(k)[source]#

Calculate the partial derivatives for combustion pressure equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the fluid equations.

combustion_pressure_func()[source]#

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equations.

\[\begin{split}0 = p_\mathrm{in,3} - p_\mathrm{out,3}\\ 0 = p_\mathrm{in,3} - p_\mathrm{in,4}\end{split}\]

combustion_pressure_func_doc(label)[source]#

Equations for reactor pressure balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static component()[source]#
convergence_check()[source]#

Perform a convergence check.

Note

Manipulate enthalpies/pressure at inlet and outlet if not specified by user to match physically feasible constraints, keep fluid composition within feasible range and then propagates it towards the outlet.

energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

energy_balance_func()[source]#

Calculate the energy balance of the adiabatic combustion chamber.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & -\dot{m}_{out,2}\cdot\left( h_{out,1}-h_{out,1,ref} \right)\\ & + LHV_{fuel} \cdot\left(\sum_i\dot{m}_{in,i}\cdot x_{fuel,in,i}- \dot{m}_{out,1} \cdot x_{fuel} \right) \end{split}\\\end{split}\\\forall i \in \text{inlets}\end{aligned}\end{align} \]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the state of the water in the flue gas is fored to gaseous.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_balance_func_doc(label)[source]#

Calculate the energy balance of the adiabatic combustion chamber.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of combustion chamber.

Note

The entropy balance makes the following parameter available:

  • T_mcomb: Thermodynamic temperature of heat of combustion

  • S_comb: Entropy production due to combustion

  • S_irr: Entropy production due to irreversibilty

The methodology for entropy analysis of combustion processes is derived from [19]. Similar to the energy balance of a combustion reaction, we need to define the same reference state for the entropy balance of the combustion. The temperature for the reference state is set to 25 °C and reference pressure is 1 bar. As the water in the flue gas may be liquid but the thermodynmic temperature of heat of combustion refers to the lower heating value, the water is forced to gas at the reference point by considering evaporation.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

\[\begin{split}T_\mathrm{m,comb}= \frac{\dot{m}_\mathrm{fuel} \cdot LHV} {\dot{S}_\mathrm{comb}}\\ \dot{S}_\mathrm{comb}= \dot{m}_\mathrm{fluegas} \cdot \left(s_\mathrm{fluegas}-s_\mathrm{fluegas,ref}\right) - \sum_{i=1}^2 \dot{m}_{\mathrm{in,}i} \cdot \left( s_{\mathrm{in,}i} - s_{\mathrm{in,ref,}i} \right)\\ \dot{S}_\mathrm{irr}= 0\\\end{split}\]
exergy_balance(T0)[source]#

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]#
get_parameters()[source]#
static initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static is_branch_source()[source]#
lambda_deriv(increment_filter, k)[source]#

Calculate partial derivatives of lambda function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

lambda_func()[source]#

Calculate the residual for specified lambda.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \frac{\dot{m}_{f,m}}{\dot{m}_{O_2,m} \cdot \left(n_{C,fuel} + 0.25 \cdot n_{H,fuel}\right)} - \lambda\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in inlets\end{split}\end{aligned}\end{align} \]

lambda_func_doc(label)[source]#

Calculate the residual for specified lambda.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

mass_flow_deriv(k)[source]#

Calculate the partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the fluid equations.

mass_flow_func()[source]#

Calculate the residual value for component’s mass flow balance.

Returns:

residual (list) – Vector with residual value for component’s mass flow balance.

\[0 = \dot{m}_{in,1} + \dot{m}_{in,2} - \dot{m}_{out,1}\]

mass_flow_func_doc(label)[source]#

Calculate the residual value for component’s mass flow balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
setup_reaction_parameters()[source]#

Setup parameters for reaction (gas name aliases and LHV).

start_branch()[source]#
stoichiometry(fluid)[source]#

Calculate the reaction balance for one fluid.

  • determine molar mass flows of fuel and oxygen

  • calculate mole number of carbon and hydrogen atoms in fuel

  • calculate molar oxygen flow for stoichiometric combustion

  • calculate residual value for the corresponding fluid

for excess fuel

  • calculate excess carbon and hydrogen in fuels

  • calculate excess fuel shares

General equations

\[ \begin{align}\begin{aligned}\begin{split}res = \sum_i \left(x_{fluid,i} \cdot \dot{m}_{i}\right) - \sum_j \left(x_{fluid,j} \cdot \dot{m}_{j}\right)\\ \forall i \in \text{combustion inlets}\\ \forall j \in text{flue gas outlet}\end{split}\\\begin{split}\dot{m}_{fluid,m} = \sum_i \frac{x_{fluid,i} \cdot \dot{m}_{i}} {M_{fluid}}\\ \forall i \in \text{combustion inlets}\end{split}\\\dot{m}_{O_2,m,stoich}=\frac{\dot{m}_{H_m}}{4} + \dot{m}_{C_m}\\\lambda = \frac{\dot{m}_{O_2,m}}{\dot{m}_{O_2,m,stoich}}\end{aligned}\end{align} \]

Excess carbon and hydrogen

\[ \begin{align}\begin{aligned}\begin{split}\dot{m}_{H_{exc,m}} = \begin{cases} 0 & \lambda \geq 1\\ 4 \cdot \left( \dot{m}_{O_2,m,stoich} - \dot{m}_{O_2,m}\right) & \lambda < 1 \end{cases}\end{split}\\\begin{split}\dot{m}_{C_{exc,m}} = \begin{cases} 0 & \lambda \geq 1\\ \dot{m}_{O_2,m,stoich} - \dot{m}_{O_2,m} & \lambda < 1 \end{cases}\end{split}\end{aligned}\end{align} \]

Equation for fuels

\[ \begin{align}\begin{aligned}\begin{split}0 = res - \left(\dot{m}_{f,m} - \dot{m}_{f,exc,m}\right) \cdot M_{fuel}\\\end{split}\\\begin{split}\dot{m}_{f,exc,m} = \begin{cases} 0 & \lambda \geq 1\\ \dot{m}_{f,m} - \frac{\dot{m}_{O_2,m}} {n_{C,fuel} + 0.25 \cdot n_{H,fuel}} \end{cases}\end{split}\end{aligned}\end{align} \]

Equation for oxygen

\[\begin{split}0 = res - \begin{cases} -\frac{\dot{m}_{O_2,m} \cdot M_{O_2}}{\lambda} & \lambda \geq 1\\ - \dot{m}_{O_2,m} \cdot M_{O_2} & \lambda < 1 \end{cases}\end{split}\]

Equation for water

\[0 = res + \left( \dot{m}_{H_m} - \dot{m}_{H_{exc,m}} \right) \cdot 0.5 \cdot M_{H_2O}\]

Equation for carbondioxide

\[0 = res + \left( \dot{m}_{C_m} - \dot{m}_{C_{exc,m}} \right) \cdot M_{CO_2}\]

Equation for all other fluids

\[0 = res\]
Parameters:

fluid (str) – Fluid to calculate residual value for.

Returns:

residual (float) – Residual value for corresponding fluid.

stoichiometry_deriv(increment_filter, k)[source]#

Calculate partial derivatives of the reaction balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

stoichiometry_func()[source]#

Collect residual values for all fluids in stoichiometry.

Returns:

residual (list) – Vector with residual values of equations.

stoichiometry_func_doc(label)[source]#

Generate stoichiometry LaTeX equations.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

ti_deriv(increment_filter, k)[source]#

Calculate partial derivatives of thermal input function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

ti_func()[source]#

Calculate the residual for specified thermal input.

Returns:

residual (float) – Residual value of function.

\[0 = ti - \dot{m}_{fuel} \cdot LHV\]

ti_func_doc(label)[source]#

Calculate the residual for specified thermal input.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.combustion.diabatic module#

Module of class CombustionChamber.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/diabatic.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.diabatic.DiabaticCombustionChamber(label, **kwargs)[source]#

Bases: CombustionChamber

The class CombustionChamber is parent class of all combustion components.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamberflowsheet of the combustion chamber

Note

The fuel and the air components can be connected to either of the inlets. The pressure of inlet 2 is disconnected from the pressure of inlet 1. A warning is prompted, if the pressure at inlet 2 is lower than the pressure at inlet 1.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Actual oxygen to stoichiometric oxygen ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

  • eta (float, dict) – Combustion thermal efficiency, \(\eta\). Heat loss calculation based on share of thermal input.

  • pr (float, dict) – Pressure ratio of outlet 1 to inlet 1, \(pr\).

Note

For more information on the usage of the combustion chamber see the examples section on github or look for the combustion chamber tutorials at tespy.readthedocs.io.

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel.

>>> from tespy.components import Sink, Source, DiabaticCombustionChamber
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.fluid_properties import T_sat_p
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> amb = Source('ambient air')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> comb = DiabaticCombustionChamber('combustion chamber')
>>> comb.component()
'diabatic combustion chamber'
>>> amb_comb = Connection(amb, 'out1', comb, 'in1')
>>> sf_comb = Connection(sf, 'out1', comb, 'in2')
>>> comb_fg = Connection(comb, 'out1', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)

Specify the thermal input of the combustion chamber. At the given fluid compositions this determines the mass flow of the fuel. The outlet temperature of the flue gas determines the ratio of oxygen to fuel mass flow. In contrast to the simple combustion chamber, this component does allow for a pressure drop. Therefore the outlet pressure or the pressure ratio of the combustion chamber must be specified. Since the component is not adiabatic, an efficiency value eta can be supplied to account for heat loss to the ambient. First, we specify eta=1 and expect identical lambda or outlet temperature as in an adiabatic combustion chamber.

>>> comb.set_attr(ti=500000, pr=0.95, eta=1, lamb=1.5)
>>> amb_comb.set_attr(p=1.2, T=20, fluid={'Ar': 0.0129, 'N2': 0.7553,
... 'CO2': 0.0004, 'O2': 0.2314})
>>> sf_comb.set_attr(T=25, fluid={'CO2': 0.03, 'H2': 0.01, 'CH4': 0.96}, p=1.3)
>>> nw.solve('design')
>>> comb_fg.set_attr(T=1200)
>>> comb.set_attr(lamb=None)
>>> nw.solve('design')
>>> round(comb.lamb.val, 3)
2.014
>>> round(comb_fg.p.val, 2)
1.14

Instead of the pressure ration, we can also specify the outlet pressure. The pressure ratio is the ratio or pressure at the outlet to the pressure at the inlet 1 (ambient air inlet in this example).

>>> comb.set_attr(pr=None)
>>> comb_fg.set_attr(p=1)
>>> nw.solve('design')
>>> round(comb.pr.val, 3)
0.833

We can change lambda to a specific value and unset the flue gas temperature:

>>> comb.set_attr(lamb=2)
>>> comb_fg.set_attr(T=None)
>>> nw.solve('design')
>>> round(comb_fg.T.val, 1)
1206.5

Now, if we change the efficiency value, e.g. to 0.9, a total of 10 % of heat respective to the thermal input will be transferred to the ambient. Note, that the heat loss Q_loss has a negative value as it is extracted from the system.

>>> eta = 0.9
>>> comb.set_attr(eta=eta)
>>> nw.solve('design')
>>> round(comb.Q_loss.val, 0)
-50000.0
>>> round(comb.ti.val * comb.eta.val, 0)
450000.0
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_balance_func()[source]#

Calculate the energy balance of the diabatic combustion chamber.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & -\dot{m}_{out,2}\cdot\left( h_{out,1}-h_{out,1,ref} \right)\\ & + LHV_{fuel} \cdot\left(\sum_i\dot{m}_{in,i}\cdot x_{fuel,in,i}- \dot{m}_{out,1} \cdot x_{fuel} \right) \cdot \eta \end{split}\\\end{split}\\\forall i \in \text{inlets}\end{aligned}\end{align} \]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the state of the water in the flue gas is fored to gaseous.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_balance_func_doc(label)[source]#

Calculate the energy balance of the diabatic combustion chamber.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

exergy_balance(T0)[source]#

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]#
get_parameters()[source]#
pr_deriv(increment_filter, k)[source]#

Calculate the partial derivatives for combustion pressure ratio.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

pr_func()[source]#

Equation for pressure drop.

Returns:

residual (float) – Residual value of equation.

\[0 = p_\mathrm{in,1} \cdot pr - p_\mathrm{out,1}\]

pr_func_doc(label)[source]#

Equation for inlet pressure equality.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.combustion.engine module#

Module of class CombustionEngine.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/combustion/engine.py

SPDX-License-Identifier: MIT

class tespy.components.combustion.engine.CombustionEngine(label, **kwargs)[source]#

Bases: CombustionChamber

An internal combustion engine supplies power and heat cogeneration.

The combustion engine produces power and heat in cogeneration from fuel combustion. The combustion properties are identical to the combustion chamber. Thermal input and power output, heat output and heat losses are linked with an individual characteristic line for each property.

Mandatory Equations

Optional Equations

Available fuels

  • methane, ethane, propane, butane, hydrogen

Inlets/Outlets

  • in1, in2 (cooling water), in3, in4 (air and fuel)

  • out1, out2 (cooling water), out3 (flue gas)

Image

flowsheet of the combustion engineflowsheet of the combustion engine

Note

The fuel and the air components can be connected to either of the inlets.

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • lamb (float, dict) – Air to stoichiometric air ratio, \(\lambda/1\).

  • ti (float, dict) – Thermal input, (\({LHV \cdot \dot{m}_f}\)), \(ti/\text{W}\).

  • P (float, dict, "var") – Power output, \(P/\text{W}\).

  • Q1 (float, dict) – Heat output 1, \(\dot Q/\text{W}\).

  • Q2 (float, dict) – Heat output 2, \(\dot Q/\text{W}\).

  • Qloss (float, dict, "var") – Heat loss, \(\dot Q_{loss}/\text{W}\).

  • pr1 (float, dict, "var") – Pressure ratio heat outlet 1, \(pr/1\).

  • pr2 (float, dict, "var") – Pressure ratio heat outlet 2, \(pr/1\).

  • zeta1 (float, dict, "var") – Geometry independent friction coefficient heating loop 1, \(\zeta_1/\frac{1}{\text{m}^4}\).

  • zeta2 (float, dict, "var") – Geometry independent friction coefficient heating loop 2, \(\zeta_2/\frac{1}{\text{m}^4}\).

  • tiP_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking fuel input to power output.

  • Q1_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat output 1 to power output.

  • Q2_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat output 2 to power output.

  • Qloss_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line linking heat loss to power output.

  • eta_mech (float) – Value of internal efficiency of the combustion engine. This value is required to determine the (virtual) thermodynamic temperature of heat inside the combustion engine for the entropy balance calculation. Default value is 0.85.

Note

Parameters available through entropy balance are listed in the respective method:

Example

The combustion chamber calculates energy input due to combustion as well as the flue gas composition based on the type of fuel and the amount of oxygen supplied. In this example a mixture of methane, hydrogen and carbondioxide is used as fuel. There are two cooling ports, the cooling water will flow through them in parallel.

>>> from tespy.components import (Sink, Source, CombustionEngine, Merge,
... Splitter)
>>> from tespy.connections import Connection, Ref
>>> from tespy.networks import Network
>>> import numpy as np
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> amb = Source('ambient')
>>> sf = Source('fuel')
>>> fg = Sink('flue gas outlet')
>>> cw_in = Source('cooling water inlet')
>>> sp = Splitter('cooling water splitter', num_out=2)
>>> me = Merge('cooling water merge', num_in=2)
>>> cw_out = Sink('cooling water outlet')
>>> chp = CombustionEngine(label='internal combustion engine')
>>> chp.component()
'combustion engine'
>>> amb_comb = Connection(amb, 'out1', chp, 'in3')
>>> sf_comb = Connection(sf, 'out1', chp, 'in4')
>>> comb_fg = Connection(chp, 'out3', fg, 'in1')
>>> nw.add_conns(sf_comb, amb_comb, comb_fg)
>>> cw_sp = Connection(cw_in, 'out1', sp, 'in1')
>>> sp_chp1 = Connection(sp, 'out1', chp, 'in1')
>>> sp_chp2 = Connection(sp, 'out2', chp, 'in2')
>>> chp1_me = Connection(chp, 'out1', me, 'in1')
>>> chp2_me = Connection(chp, 'out2', me, 'in2')
>>> me_cw = Connection(me, 'out1', cw_out, 'in1')
>>> nw.add_conns(cw_sp, sp_chp1, sp_chp2, chp1_me, chp2_me, me_cw)

The combustion engine produces a power output of 10 MW the oxygen to stoichiometric oxygen ratio is set to 1. Only pressure ratio 1 is set as we reconnect both cooling water streams. At the merge all pressure values will be identical automatically. Reference the mass flow at the splitter to be split in half.

>>> chp.set_attr(pr1=0.99, P=-10e6, lamb=1.0,
... design=['pr1'], offdesign=['zeta1'])
>>> amb_comb.set_attr(p=5, T=30, fluid={'Ar': 0.0129, 'N2': 0.7553,
... 'CO2': 0.0004, 'O2': 0.2314})
>>> sf_comb.set_attr(T=30, fluid={'CH4': 1})
>>> cw_sp.set_attr(p=3, T=60, m=50, fluid={'H2O': 1})
>>> sp_chp2.set_attr(m=Ref(sp_chp1, 1, 0))
>>> mode = 'design'
>>> nw.solve(mode=mode)
>>> nw.save('tmp')
>>> round(chp.ti.val, 0)
25300000.0
>>> round(chp.Q1.val, 0)
-4980000.0
>>> chp.set_attr(Q1=-4e6, P=None)
>>> mode = 'offdesign'
>>> nw.solve(mode=mode, init_path='tmp', design_path='tmp')
>>> round(chp.ti.val, 0)
17794554.0
>>> round(chp.P.val / chp.P.design, 3)
0.617
>>> chp.set_attr(P=chp.P.design * 0.75, Q1=None)
>>> mode = 'offdesign'
>>> nw.solve(mode=mode, init_path='tmp', design_path='tmp')
>>> round(chp.ti.val, 0)
20550000.0
>>> round(chp.P.val / chp.P.design, 3)
0.75
>>> shutil.rmtree('./tmp', ignore_errors=True)
Q1_char_deriv(increment_filter, k)[source]#

Calculate partial derivatives of primary heat to thermal input char.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

Q1_char_func()[source]#

Calculate the relation of heat output 1 and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{m}_1 \cdot \left(h_{out,1} - h_{in,1} \right) \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & - LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{Q1}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Q1_char_func_doc(label)[source]#

Calculate the relation of heat output 1 and thermal input.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

Q1_deriv(increment_filter, k)[source]#

Calculate partial derivatives of primary heat loop function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

Q1_func()[source]#

Calculate residual value of primary heat loop function.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_1 \cdot \left(h_{out,1} + h_{in,1} \right) + \dot{Q}_1\]

Q1_func_doc(label)[source]#

Calculate residual value of primary heat loop function.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

Q2_char_deriv(increment_filter, k)[source]#

Calculate partial derivatives of secondary heat to thermal input char.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

Q2_char_func()[source]#

Calculate the relation of heat output 2 and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{m}_2 \cdot \left(h_{out,2} - h_{in,2} \right) \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & - LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{Q2}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Q2_char_func_doc(label)[source]#

Calculate the relation of heat output 2 and thermal input.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

Q2_deriv(increment_filter, k)[source]#

Calculate partial derivatives of secondary heat loop function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

Q2_func()[source]#

Calculate residual value of secondary heat loop function.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_2 \cdot \left(h_{out,2} - h_{in,2} \right) + \dot{Q}_2\]

Q2_func_doc(label)[source]#

Calculate residual value of secondary heat loop function.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

Qloss_char_deriv(increment_filter, k)[source]#

Calculate partial derivatives of heat loss to thermal input char.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

Qloss_char_func()[source]#

Calculate the relation of heat loss and thermal input.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{Q}_{loss} \cdot f_{TI}\left(\frac{P}{P_{design}}\right) \\ & + LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \cdot f_{QLOSS}\left(\frac{P}{P_{ref}}\right)\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Qloss_char_func_doc(label)[source]#

Calculate the relation of heat loss and thermal input.

Parameters:

label (str) – Label for equation.

bus_deriv(bus)[source]#

Calculate the matrix of partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

residual (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\begin{split}\dot{E} = \begin{cases} LHV \cdot \dot{m}_{f} & \text{key = 'TI'}\\ P & \text{key = 'P'}\\ -\dot{m}_1 \cdot \left( h_{1,out} - h_{1,in} \right) -\dot{m}_2 \cdot \left( h_{2,out} - h_{2,in} \right) & \text{key = 'Q'}\\ -\dot{m}_1 \cdot \left( h_{1,out} - h_{1,in} \right) & \text{key = 'Q1'}\\ -\dot{m}_2 \cdot \left( h_{2,out} - h_{2,in} \right) & \text{key = 'Q2'}\\ \dot{Q}_{loss} & \text{key = 'Qloss'} \end{cases}\end{split}\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_P()[source]#

Calculate the power output of the combustion engine.

Returns:

P (float) – Power output.

\[P = -\frac{LHV \cdot \dot{m}_{f}} {f_{TI}\left(\frac{P}{P_{ref}}\right)}\]

calc_Qloss()[source]#

Calculate the heat loss of the combustion engine.

Returns:

Qloss (float) – Heat loss.

\[\dot{Q}_{loss} = -\frac{LHV \cdot \dot{m}_{f} \cdot f_{QLOSS}\left(\frac{P}{P_{ref}}\right)} {f_{TI}\left(\frac{P}{P_{ref}}\right)}\]

calc_parameters()[source]#

Postprocessing parameter calculation.

check_parameter_bounds()[source]#

Check parameter value limits.

static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

energy_balance_func()[source]#

Calculate the energy balance of the combustion engine.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \sum_i \dot{m}_{in,i} \cdot \left( h_{in,i} - h_{in,i,ref} \right)\\ & - \sum_j \dot{m}_{out,3} \cdot \left( h_{out,3} - h_{out,3,ref} \right)\\ & + LHV_{fuel} \cdot \left(\sum_i \left(\dot{m}_{in,i} \cdot x_{fuel,i} \right)- \dot{m}_{out,3} \cdot x_{fuel,3} \right)\\ & - \dot{Q}_1 - \dot{Q}_2 - P - \dot{Q}_{loss}\\ \end{split}\\ \forall i \in [3,4]\end{split}\]

Note

The temperature for the reference state is set to 25 °C, thus the water may be liquid. In order to make sure, the state is referring to the lower heating value, the necessary enthalpy difference for evaporation is added.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_balance_func_doc(label)[source]#

Calculate the energy balance of the combustion engine.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of combustion engine.

For the entropy balance of a combustion engine two additional parameters need to be specified:

  • virtual inner temperature T_v_inner that is used to determine the entropy of heat transferred from the hot side.

  • mechanical efficiency eta_mech describing the ratio of power output P to reversible power of the motor [20]. It is used to determine the irreversibilty inside the motor.

    \[P_\mathrm{irr,inner}=\left(1 - \frac{1}{\eta_\mathrm{mech}} \right) \cdot P\]

The default values are:

  • T_v_inner: flue gas temperature (result of calculation)

  • eta_mech: 0.85

Note

The entropy balance makes the following parameter available:

  • T_mcomb: Thermodynamic temperature of heat of combustion

  • S_comb: Entropy production due to combustion

  • T_mQ1: Thermodynamic temperature of heat at cold side of heater 1

  • S_Q11: Entropy transport at hot side of heater 1

  • S_Q12: Entropy transport at cold side of heater 1

  • S_Q1irr: Entropy production due to heat transfer at heater 1

  • S_irr1: Entropy production due to pressure losses at heater 1

  • T_mQ2: Thermodynamic temperature of heat at cold side of heater 2

  • S_Q21: Entropy transport at hot side of heater 2

  • S_Q22: Entropy transport at cold side of heater 2

  • S_Q2irr: Entropy production due to heat transfer at heater 2

  • S_irr2: Entropy production due to pressure losses at heater 2

  • S_irr_i: Entropy production due to internal irreversibilty

  • S_Qloss: Entropy transport with heat loss to ambient

  • S_Qcomb: Virtual entropy transport of heat to revert combustion gases to reference state

  • S_irr: Total entropy production due to irreversibilty

The methodology for entropy analysis of combustion processes is derived from [19]. Similar to the energy balance of a combustion reaction, we need to define the same reference state for the entropy balance of the combustion. The temperature for the reference state is set to 25 °C and reference pressure is 1 bar. As the water in the flue gas may be liquid but the thermodynmic temperature of heat of combustion refers to the lower heating value, the water is forced to gas at the reference point by considering evaporation.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

\[\begin{split}\begin{split} T_\mathrm{m,comb}= & \frac{\dot{m}_\mathrm{fuel} \cdot LHV} {\dot{S}_\mathrm{comb}}\\ \dot{S}_\mathrm{comb} =&\dot{S}_\mathrm{Q,comb}-\left( \dot{S}_\mathrm{Q,11} + \dot{S}_\mathrm{Q,21} + \dot{S}_\mathrm{Q,loss} +\dot{S}_\mathrm{irr,i}\right)\\ \dot{S}_\mathrm{Q,comb}= & \dot{m}_\mathrm{fluegas} \cdot \left(s_\mathrm{fluegas}-s_\mathrm{fluegas,ref}\right)\\ & - \sum_{i=3}^4 \dot{m}_{\mathrm{in,}i} \cdot \left( s_{\mathrm{in,}i} - s_{\mathrm{in,ref,}i} \right)\\ \dot{S}_\mathrm{Q,11}= & \frac{\dot{Q}_1}{T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{Q,21}= & \frac{\dot{Q}_2}{T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{Q,loss}= & \frac{\dot{Q}_\mathrm{loss}} {T_\mathrm{v,inner}}\\ \dot{S}_\mathrm{irr,i}= & \frac{\left(1 - \frac{1}{\eta_\mathrm{mech}}\right) \cdot P}{T_\mathrm{v,inner}}\\ T_\mathrm{Q,12} = &\frac{-\dot{Q}_1}{\dot{m}_1 \cdot \left( s_\mathrm{out,1} - s_\mathrm{in,1}\right)}\\ T_\mathrm{Q,22} = &\frac{-\dot{Q}_2}{\dot{m}_2 \cdot \left( s_\mathrm{out,2} - s_\mathrm{in,2}\right)}\\ \dot{S}_\mathrm{irr} = &\sum \dot{S}_\mathrm{irr}\\ \end{split}\\\end{split}\]
exergy_balance(T0)[source]#

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]#
get_parameters()[source]#
static initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
tiP_char_deriv(increment_filter, k)[source]#

Calculate partial derivatives of power to thermal input characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of equation in Jacobian matrix.

tiP_char_func()[source]#

Calculate the relation of output power and thermal input.

Returns:

residual (float) – Residual value of equation.

\[0 = P \cdot f_{TI}\left(\frac{P}{P_{design}}\right)+ LHV \cdot \left[\sum_i \left(\dot{m}_{in,i} \cdot x_{f,i}\right) - \dot{m}_{out,3} \cdot x_{f,3} \right] \; \forall i \in [3,4]\]

tiP_char_func_doc(label)[source]#

Calculate the relation of output power and thermal input.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.heat_exchangers.condenser module#

Module of class Condenser.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/condenser.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.condenser.Condenser(label, **kwargs)[source]#

Bases: HeatExchanger

A Condenser cools a fluid until it is in liquid state.

The condensing fluid is cooled by the cold side fluid. The fluid on the hot side of the condenser must be pure. Subcooling is available.

Mandatory Equations

Optional Equations

Inlets/Outlets

  • in1, in2 (index 1: hot side, index 2: cold side)

  • out1, out2 (index 1: hot side, index 2: cold side)

Image

flowsheet of the condenserflowsheet of the condenser
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict) – Heat transfer, \(Q/\text{W}\).

  • pr1 (float, dict, "var") – Outlet to inlet pressure ratio at hot side, \(pr/1\).

  • pr2 (float, dict, "var") – Outlet to inlet pressure ratio at cold side, \(pr/1\).

  • zeta1 (float, dict, "var") – Geometry independent friction coefficient at hot side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • zeta2 (float, dict, "var") – Geometry independent friction coefficient at cold side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • ttd_l (float, dict) – Lower terminal temperature difference \(ttd_\mathrm{l}/\text{K}\).

  • ttd_u (float, dict) – Upper terminal temperature difference (referring to saturation temprature of condensing fluid) \(ttd_\mathrm{u}/\text{K}\).

  • kA (float, dict) – Area independent heat transfer coefficient, \(kA/\frac{\text{W}}{\text{K}}\).

  • kA_char (tespy.tools.data_containers.SimpleDataContainer) – Area independent heat transfer coefficient characteristic.

  • kA_char1 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for hot side heat transfer coefficient.

  • kA_char2 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for cold side heat transfer coefficient.

  • subcooling (boolean) – Enable/disable subcooling, default value: disabled.

Note

The condenser has an additional equation for enthalpy at hot side outlet: The fluid leaves the component in saturated liquid state. If subcooling is activated, it possible to specify the enthalpy at the outgoing connection manually.

It has different calculation method for given heat transfer coefficient and upper terminal temperature dierence: These parameters refer to the condensing temperature, even if the fluid on the hot side enters the component in superheated state.

Example

Air is used to condensate water in a condenser. 1 kg/s waste steam is chilled with a terminal temperature difference of 15 K.

>>> from tespy.components import Sink, Source, Condenser
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.fluid_properties import T_sat_p
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', h_unit='kJ / kg',
... m_range=[0.01, 1000], iterinfo=False)
>>> amb_in = Source('ambient air inlet')
>>> amb_out = Sink('air outlet')
>>> waste_steam = Source('waste steam')
>>> c = Sink('condensate sink')
>>> cond = Condenser('condenser')
>>> cond.component()
'condenser'
>>> amb_he = Connection(amb_in, 'out1', cond, 'in2')
>>> he_amb = Connection(cond, 'out2', amb_out, 'in1')
>>> ws_he = Connection(waste_steam, 'out1', cond, 'in1')
>>> he_c = Connection(cond, 'out1', c, 'in1')
>>> nw.add_conns(amb_he, he_amb, ws_he, he_c)

The air flow can not be controlled, thus is constant in offdesign operation. If the waste steam mass flow or the ambient air temperature change, the outlet temperature of the air will change, too.

>>> cond.set_attr(pr1=0.98, pr2=0.999, ttd_u=15, design=['pr2', 'ttd_u'],
... offdesign=['zeta2', 'kA_char'])
>>> ws_he.set_attr(fluid={'water': 1}, h=2700, m=1)
>>> amb_he.set_attr(fluid={'air': 1}, T=20, offdesign=['v'])
>>> he_amb.set_attr(p=1, T=40, design=['T'])
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(amb_he.v.val, 2)
103.17
>>> round(ws_he.T.val - he_amb.T.val, 1)
66.9
>>> round(ws_he.calc_T_sat() - 273.15 - he_amb.T.val, 1)
15.0
>>> ws_he.set_attr(m=0.7)
>>> amb_he.set_attr(T=30)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(ws_he.T.val - he_amb.T.val, 1)
62.5
>>> round(ws_he.calc_T_sat() - 273.15 - he_amb.T.val, 1)
11.3

It is possible to activate subcooling. The difference to boiling point temperature is specified to 5 K.

>>> cond.set_attr(subcooling=True)
>>> he_c.set_attr(Td_bp=-5)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(ws_he.T.val - he_amb.T.val, 1)
62.5
>>> round(ws_he.calc_T_sat() - 273.15 - he_amb.T.val, 1)
13.4
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

calculate_td_log()[source]#
static component()[source]#
get_parameters()[source]#
kA_char_func()[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1}\right) + kA_{design} \cdot f_{kA} \cdot \frac{T_{out,1} - T_{in,2} - T_{sat} \left(p_{in,1}\right) + T_{out,2}} {\ln{\frac{T_{out,1} - T_{in,2}} {T_{sat} \left(p_{in,1}\right) - T_{out,2}}}}\\f_{kA} = \frac{2}{\frac{1}{f_1 \left( expr_1\right)} + \frac{1}{f_2 \left( expr_2\right)}}\end{aligned}\end{align} \]

Note

For standard functions f1 and f2 see module tespy.data.

kA_char_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

kA_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

subcooling_deriv(increment_filter, k)[source]#

Calculate partial derivates of subcooling function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

subcooling_func()[source]#

Equation for hot side outlet state.

Returns:

residual (float) – Residual value of equation.

\[0=h_{out,1} -h\left(p_{out,1}, x=0 \right)\]

Note

This equation is applied in case subcooling is False!

subcooling_func_doc(label)[source]#

Equation for hot side outlet state.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

ttd_u_func()[source]#

Equation for upper terminal temperature difference.

Returns:

residual (float) – Residual value of equation.

\[0 = ttd_{u} - T_{sat} \left(p_{in,1}\right) + T_{out,2}\]

Note

The upper terminal temperature difference ttd_u refers to boiling temperature at hot side inlet.

ttd_u_func_doc(label)[source]#

Equation for upper terminal temperature difference.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.heat_exchangers.desuperheater module#

Module of class Desuperheater.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/desuperheater.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.desuperheater.Desuperheater(label, **kwargs)[source]#

Bases: HeatExchanger

The Desuperheater cools a fluid to the saturated gas state.

Mandatory Equations

Optional Equations

Inlets/Outlets

  • in1, in2 (index 1: hot side, index 2: cold side)

  • out1, out2 (index 1: hot side, index 2: cold side)

Image

flowsheet of the desuperheaterflowsheet of the desuperheater
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict) – Heat transfer, \(Q/\text{W}\).

  • pr1 (float, dict, "var") – Outlet to inlet pressure ratio at hot side, \(pr/1\).

  • pr2 (float, dict, "var") – Outlet to inlet pressure ratio at cold side, \(pr/1\).

  • zeta1 (float, dict, "var") – Geometry independent friction coefficient at hot side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • zeta2 (float, dict, "var") – Geometry independent friction coefficient at cold side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • ttd_l (float, dict) – Lower terminal temperature difference \(ttd_\mathrm{l}/\text{K}\).

  • ttd_u (float, dict) – Upper terminal temperature difference \(ttd_\mathrm{u}/\text{K}\).

  • kA (float, dict) – Area independent heat transfer coefficient, \(kA/\frac{\text{W}}{\text{K}}\).

  • kA_char1 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for hot side heat transfer coefficient.

  • kA_char2 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for cold side heat transfer coefficient.

Note

The desuperheater has an additional equation for enthalpy at hot side outlet: The fluid leaves the component in saturated gas state.

Example

Overheated enthanol is cooled with water in a heat exchanger until it reaches the state of saturated gas.

>>> from tespy.components import Sink, Source, Desuperheater
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', h_unit='kJ / kg', v_unit='l / s',
... m_range=[0.001, 10], iterinfo=False)
>>> et_in = Source('ethanol inlet')
>>> et_out = Sink('ethanol outlet')
>>> cw_in = Source('cooling water inlet')
>>> cw_out = Sink('cooling water outlet')
>>> desu = Desuperheater('desuperheater')
>>> desu.component()
'desuperheater'
>>> et_de = Connection(et_in, 'out1', desu, 'in1')
>>> de_et = Connection(desu, 'out1', et_out, 'in1')
>>> cw_de = Connection(cw_in, 'out1', desu, 'in2')
>>> de_cw = Connection(desu, 'out2', cw_out, 'in1')
>>> nw.add_conns(et_de, de_et, cw_de, de_cw)

The cooling water enters the component at 15 °C. 10 l/s of ethanol is cooled from 100 K above boiling point. The water flow rate is at 1 l/s. Knowing the component’s design parameters it is possible to predict behavior at different inlet temperatures or different volumetric flow of ethanol. Controlling the ethanol’s state at the outlet is only possible, if the cooling water flow rate is adjusted accordingly.

>>> desu.set_attr(pr1=0.99, pr2=0.98, design=['pr1', 'pr2'],
... offdesign=['zeta1', 'zeta2', 'kA_char'])
>>> cw_de.set_attr(fluid={'water': 1}, T=15, v=1,
... design=['v'])
>>> de_cw.set_attr(p=1)
>>> et_de.set_attr(fluid={'ethanol': 1}, Td_bp=100, v=10)
>>> de_et.set_attr(p=1)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(de_cw.T.val, 1)
15.5
>>> round(de_et.x.val, 1)
1.0
>>> et_de.set_attr(v=12)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(cw_de.v.val, 2)
1.94
>>> et_de.set_attr(v=7)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(cw_de.v.val, 2)
0.41
>>> shutil.rmtree('./tmp', ignore_errors=True)
static component()[source]#
get_mandatory_constraints()[source]#
saturated_gas_deriv(increment_filter, k)[source]#

Partial derivatives of saturated gas at hot side outlet function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

saturated_gas_func()[source]#

Calculate hot side outlet state.

Returns:

residual (float) – Residual value of equation

\[0 = h_{out,1} - h\left(p_{out,1}, x=1 \right)\]

saturated_gas_func_doc(label)[source]#

Calculate hot side outlet state.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.heat_exchangers.base module#

Module of class HeatExchanger.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/base.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.base.HeatExchanger(label, **kwargs)[source]#

Bases: Component

Class for counter current heat exchanger.

The component HeatExchanger is the parent class for the components:

Mandatory Equations

Optional Equations

Inlets/Outlets

  • in1, in2 (index 1: hot side, index 2: cold side)

  • out1, out2 (index 1: hot side, index 2: cold side)

Image

flowsheet of the heat exchangerflowsheet of the heat exchanger
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict) – Heat transfer, \(Q/\text{W}\).

  • pr1 (float, dict, "var") – Outlet to inlet pressure ratio at hot side, \(pr/1\).

  • pr2 (float, dict, "var") – Outlet to inlet pressure ratio at cold side, \(pr/1\).

  • zeta1 (float, dict, "var") – Geometry independent friction coefficient at hot side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • zeta2 (float, dict, "var") – Geometry independent friction coefficient at cold side, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • ttd_l (float, dict) – Lower terminal temperature difference \(ttd_\mathrm{l}/\text{K}\).

  • ttd_u (float, dict) – Upper terminal temperature difference \(ttd_\mathrm{u}/\text{K}\).

  • kA (float, dict) – Area independent heat transfer coefficient, \(kA/\frac{\text{W}}{\text{K}}\).

  • kA_char (dict) – Area independent heat transfer coefficient characteristic.

  • kA_char1 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for hot side heat transfer coefficient.

  • kA_char2 (tespy.tools.characteristics.CharLine, dict) – Characteristic line for cold side heat transfer coefficient.

Note

The HeatExchanger and subclasses ( tespy.components.heat_exchangers.condenser.Condenser, tespy.components.heat_exchangers.desuperheater.Desuperheater) are countercurrent heat exchangers. Equations (kA, ttd_u, ttd_l) do not work for directcurrent and crosscurrent or combinations of different types.

Example

A water cooling is installed to transfer heat from hot exhaust air. The heat exchanger is designed for a terminal temperature difference of 5 K. From this, it is possible to calculate the heat transfer coefficient and predict water and air outlet temperature in offdesign operation.

>>> from tespy.components import Sink, Source, HeatExchanger
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools import document_model
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', h_unit='kJ / kg', iterinfo=False)
>>> exhaust_hot = Source('Exhaust air outlet')
>>> exhaust_cold = Sink('Exhaust air inlet')
>>> cw_cold = Source('cooling water inlet')
>>> cw_hot = Sink('cooling water outlet')
>>> he = HeatExchanger('waste heat exchanger')
>>> he.component()
'heat exchanger'
>>> ex_he = Connection(exhaust_hot, 'out1', he, 'in1')
>>> he_ex = Connection(he, 'out1', exhaust_cold, 'in1')
>>> cw_he = Connection(cw_cold, 'out1', he, 'in2')
>>> he_cw = Connection(he, 'out2', cw_hot, 'in1')
>>> nw.add_conns(ex_he, he_ex, cw_he, he_cw)

The volumetric flow of the air is at 100 l/s. After designing the component it is possible to predict the temperature at different flow rates or different inlet temperatures of the exhaust air.

>>> he.set_attr(pr1=0.98, pr2=0.98, ttd_u=5,
... design=['pr1', 'pr2', 'ttd_u'], offdesign=['zeta1', 'zeta2', 'kA_char'])
>>> cw_he.set_attr(fluid={'water': 1}, T=10, p=3,
... offdesign=['m'])
>>> ex_he.set_attr(fluid={'air': 1}, v=0.1, T=35)
>>> he_ex.set_attr(T=17.5, p=1, design=['T'])
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(ex_he.T.val - he_cw.T.val, 0)
5.0
>>> ex_he.set_attr(v=0.075)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(he_cw.T.val, 1)
27.5
>>> round(he_ex.T.val, 1)
14.4
>>> ex_he.set_attr(v=0.1, T=40)
>>> nw.solve('offdesign', design_path='tmp')
>>> document_model(nw)
>>> round(he_cw.T.val, 1)
33.9
>>> round(he_ex.T.val, 1)
18.8
>>> shutil.rmtree('./tmp', ignore_errors=True)
bus_deriv(bus)[source]#

Calculate partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

val (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\dot{E} = \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1} \right)\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_parameters()[source]#

Postprocessing parameter calculation.

calculate_td_log()[source]#
static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Partial derivatives of energy balance function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Equation for heat exchanger energy balance.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_{in,1} \cdot \left(h_{out,1} - h_{in,1} \right) + \dot{m}_{in,2} \cdot \left(h_{out,2} - h_{in,2} \right)\]

energy_balance_func_doc(label)[source]#

Equation for heat exchanger energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

energy_balance_hot_deriv(increment_filter, k)[source]#

Partial derivatives for hot side heat exchanger energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_hot_func()[source]#

Equation for hot side heat exchanger energy balance.

Returns:

residual (float) – Residual value of equation.

\[0 =\dot{m}_{in,1} \cdot \left(h_{out,1}-h_{in,1}\right)-\dot{Q}\]

energy_balance_hot_func_doc(label)[source]#

Equation for hot side heat exchanger energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of a heat exchanger.

The allocation of the entropy streams due to heat exchanged and due to irreversibility is performed by solving for T on both sides of the heat exchanger:

\[h_\mathrm{out} - h_\mathrm{in} = \int_\mathrm{in}^\mathrm{out} v \cdot dp - \int_\mathrm{in}^\mathrm{out} T \cdot ds\]

As solving \(\int_\mathrm{in}^\mathrm{out} v \cdot dp\) for non isobaric processes would require perfect process knowledge (the path) on how specific volume and pressure change throught the component, the heat transfer is splitted into three separate virtual processes for both sides:

  • in->in*: decrease pressure to \(p_\mathrm{in*}=p_\mathrm{in}\cdot\sqrt{\frac{p_\mathrm{out}}{p_\mathrm{in}}}\) without changing enthalpy.

  • in*->out* transfer heat without changing pressure. \(h_\mathrm{out*}-h_\mathrm{in*}=h_\mathrm{out}-h_\mathrm{in}\)

  • out*->out decrease pressure to outlet pressure \(p_\mathrm{out}\) without changing enthalpy.

Note

The entropy balance makes the follwing parameter available:

\[\begin{split}\text{S\_Q1}=\dot{m} \cdot \left(s_\mathrm{out*,1}-s_\mathrm{in*,1} \right)\\ \text{S\_Q2}=\dot{m} \cdot \left(s_\mathrm{out*,2}-s_\mathrm{in*,2} \right)\\ \text{S\_Qirr}=\text{S\_Q2} - \text{S\_Q1}\\ \text{S\_irr1}=\dot{m} \cdot \left(s_\mathrm{out,1}-s_\mathrm{in,1} \right) - \text{S\_Q1}\\ \text{S\_irr2}=\dot{m} \cdot \left(s_\mathrm{out,2}-s_\mathrm{in,2} \right) - \text{S\_Q2}\\ \text{S\_irr}=\sum \dot{S}_\mathrm{irr}\\ \text{T\_mQ1}=\frac{\dot{Q}}{\text{S\_Q1}}\\ \text{T\_mQ2}=\frac{\dot{Q}}{\text{S\_Q2}}\end{split}\]
exergy_balance(T0)[source]#

Calculate exergy balance of a heat exchanger.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \dot{E}_\mathrm{out,2}^\mathrm{T} - \dot{E}_\mathrm{in,2}^\mathrm{T} & T_\mathrm{in,1}, T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2} > T_0\\ \dot{E}_\mathrm{out,1}^\mathrm{T} - \dot{E}_\mathrm{in,1}^\mathrm{T} & T_0 \geq T_\mathrm{in,1}, T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2}\\ \dot{E}_\mathrm{out,1}^\mathrm{T} + \dot{E}_\mathrm{out,2}^\mathrm{T} & T_\mathrm{in,1}, T_\mathrm{out,2} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,1}\\ \dot{E}_\mathrm{out,1}^\mathrm{T} & T_\mathrm{in,1} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2}\\ \text{not defined (nan)} & T_\mathrm{in,1}, T_\mathrm{out,1} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,2}\\ \dot{E}_\mathrm{out,2}^\mathrm{T} & T_\mathrm{in,1}, T_\mathrm{out,1}, T_\mathrm{out,2} \geq T_0 > T_\mathrm{in,2}\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \dot{E}_\mathrm{in,1}^\mathrm{PH} - \dot{E}_\mathrm{out,1}^\mathrm{PH} + \dot{E}_\mathrm{in,2}^\mathrm{M} - \dot{E}_\mathrm{out,2}^\mathrm{M} & T_\mathrm{in,1}, T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2} > T_0\\ \dot{E}_\mathrm{in,2}^\mathrm{PH} - \dot{E}_\mathrm{out,2}^\mathrm{PH} + \dot{E}_\mathrm{in,1}^\mathrm{M} - \dot{E}_\mathrm{out,1}^\mathrm{M} & T_0 \geq T_\mathrm{in,1}, T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2}\\ \dot{E}_\mathrm{in,1}^\mathrm{PH} + \dot{E}_\mathrm{in,2}^\mathrm{PH} - \dot{E}_\mathrm{out,1}^\mathrm{M} - \dot{E}_\mathrm{out,2}^\mathrm{M} & T_\mathrm{in,1}, T_\mathrm{out,2} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,1}\\ \dot{E}_\mathrm{in,1}^\mathrm{PH} + \dot{E}_\mathrm{in,2}^\mathrm{PH} - \dot{E}_\mathrm{out,2}^\mathrm{PH} - \dot{E}_\mathrm{out,1}^\mathrm{M} & T_\mathrm{in,1} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,1}, T_\mathrm{out,2}\\ \dot{E}_\mathrm{in,1}^\mathrm{PH} - \dot{E}_\mathrm{out,1}^\mathrm{PH} + \dot{E}_\mathrm{in,2}^\mathrm{PH} - \dot{E}_\mathrm{out,2}^\mathrm{PH} & T_\mathrm{in,1}, T_\mathrm{out,1} > T_0 \geq T_\mathrm{in,2}, T_\mathrm{out,2}\\ \dot{E}_\mathrm{in,1}^\mathrm{PH} - \dot{E}_\mathrm{out,1}^\mathrm{PH} + \dot{E}_\mathrm{in,2}^\mathrm{PH} - \dot{E}_\mathrm{out,2}^\mathrm{M} & T_\mathrm{in,1}, T_\mathrm{out,1}, T_\mathrm{out,2} \geq T_0 > T_\mathrm{in,2}\\ \end{cases}\end{split}\end{aligned}\end{align} \]
get_mandatory_constraints()[source]#
get_parameters()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 4 \cdot 10^5 & \text{key = 'p'}\\ h\left(p, 200 \text{K} \right) & \text{key = 'h' at outlet 1}\\ h\left(p, 250 \text{K} \right) & \text{key = 'h' at outlet 2} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 4 \cdot 10^5 & \text{key = 'p'}\\ h\left(p, 300 \text{K} \right) & \text{key = 'h' at inlet 1}\\ h\left(p, 220 \text{K} \right) & \text{key = 'h' at outlet 2} \end{cases}\end{split}\]

static inlets()[source]#
kA_char_deriv(increment_filter, k)[source]#

Partial derivatives of heat transfer coefficient characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

kA_char_func()[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1}\right) + kA_{design} \cdot f_{kA} \cdot \frac{T_{out,1} - T_{in,2} - T_{in,1} + T_{out,2}} {\ln{\frac{T_{out,1} - T_{in,2}}{T_{in,1} - T_{out,2}}}}\\f_{kA} = \frac{2}{\frac{1}{f_1\left( expr_1\right)} + \frac{1}{f_2\left( expr_2\right)}}\end{aligned}\end{align} \]

Note

For standard functions f1 and f2 see module tespy.data.

kA_char_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

kA_deriv(increment_filter, k)[source]#

Partial derivatives of heat transfer coefficient function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

kA_func()[source]#

Calculate heat transfer from heat transfer coefficient.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1}\right) + kA \cdot \frac{T_{out,1} - T_{in,2} - T_{in,1} + T_{out,2}} {\ln{\frac{T_{out,1} - T_{in,2}}{T_{in,1} - T_{out,2}}}}\]

kA_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
ttd_l_deriv(increment_filter, k)[source]#

Calculate partial derivates of upper terminal temperature function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

ttd_l_func()[source]#

Equation for upper terminal temperature difference.

Returns:

residual (float) – Residual value of equation.

\[0 = ttd_{l} - T_{out,1} + T_{in,2}\]

ttd_l_func_doc(label)[source]#

Equation for upper terminal temperature difference.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

ttd_u_deriv(increment_filter, k)[source]#

Calculate partial derivates of upper terminal temperature function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

ttd_u_func()[source]#

Equation for upper terminal temperature difference.

Returns:

residual (float) – Residual value of equation.

\[0 = ttd_{u} - T_{in,1} + T_{out,2}\]

ttd_u_func_doc(label)[source]#

Equation for upper terminal temperature difference.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

tespy.components.heat_exchangers.simple module#

Module of class SimpleHeatExchanger.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/simple.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.simple.HeatExchangerSimple(label, **kwargs)[source]#

Bases: SimpleHeatExchanger

class tespy.components.heat_exchangers.simple.SimpleHeatExchanger(label, **kwargs)[source]#

Bases: Component

A basic heat exchanger representing a heat source or heat sink.

The component SimpleHeatExchanger is the parent class for the components:

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the simple heat exchangerflowsheet of the simple heat exchanger
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict, "var") – Heat transfer, \(Q/\text{W}\).

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • D (float, dict, "var") – Diameter of the pipes, \(D/\text{m}\).

  • L (float, dict, "var") – Length of the pipes, \(L/\text{m}\).

  • ks (float, dict, "var") – Pipe’s roughness, \(ks/\text{m}\).

  • darcy_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using darcy weissbach equation.

  • ks_HW (float, dict, "var") – Pipe’s roughness, \(ks/\text{1}\).

  • hw_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using hazen williams equation.

  • kA (float, dict, "var") – Area independent heat transfer coefficient, \(kA/\frac{\text{W}}{\text{K}}\).

  • kA_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line for heat transfer coefficient.

  • Tamb (float, dict) – Ambient temperature, provide parameter in network’s temperature unit.

  • kA_group (str, dict) – Parametergroup for heat transfer calculation from ambient temperature and area independent heat transfer coefficient kA.

Example

The SimpleHeatExchanger can be used as a sink or source of heat. This component does not simulate the secondary side of the heat exchanger. It is possible to calculate the pressure ratio with the Darcy-Weisbach equation or in case of liquid water use the Hazen-Williams equation. Also, given ambient temperature and the heat transfer coeffiecient, it is possible to predict heat transfer.

>>> from tespy.components import Sink, Source, SimpleHeatExchanger
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network()
>>> nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> so1 = Source('source 1')
>>> si1 = Sink('sink 1')
>>> heat_sink = SimpleHeatExchanger('heat sink')
>>> heat_sink.component()
'heat exchanger simple'
>>> heat_sink.set_attr(Tamb=10, pr=0.95, design=['pr'],
... offdesign=['zeta', 'kA_char'])
>>> inc = Connection(so1, 'out1', heat_sink, 'in1')
>>> outg = Connection(heat_sink, 'out1', si1, 'in1')
>>> nw.add_conns(inc, outg)

It is possible to determine the amount of heat transferred when the fluid enters the heat sink at a temperature of 200 °C and is cooled down to 150 °C. Given an ambient temperature of 10 °C this also determines the heat transfer coefficient to the ambient. Assuming a characteristic function for the heat transfer coefficient we can predict the heat transferred at variable flow rates.

>>> inc.set_attr(fluid={'N2': 1}, m=1, T=200, p=5)
>>> outg.set_attr(T=150, design=['T'])
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(heat_sink.Q.val, 0)
-52581.0
>>> round(heat_sink.kA.val, 0)
321.0
>>> inc.set_attr(m=1.25)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(heat_sink.Q.val, 0)
-56599.0
>>> round(outg.T.val, 1)
156.9
>>> inc.set_attr(m=0.75)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(heat_sink.Q.val, 1)
-47275.8
>>> round(outg.T.val, 1)
140.0
>>> shutil.rmtree('./tmp', ignore_errors=True)
bus_deriv(bus)[source]#

Calculate partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

val (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\dot{E} = \dot{m}_{in} \cdot \left( h_{out} - h_{in} \right)\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
darcy_deriv(increment_filter, k)[source]#

Calculate partial derivatives of hydro group (pressure drop).

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

darcy_func()[source]#

Equation for pressure drop calculation from darcy friction factor.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}\begin{split}0 = p_{in} - p_{out} - \frac{8 \cdot |\dot{m}_{in}| \cdot \dot{m}_{in} \cdot \frac{v_{in}+v_{out}}{2} \cdot L \cdot \lambda\left(Re, ks, D\right)}{\pi^2 \cdot D^5}\\\end{split}\\\begin{split}Re = \frac{4 \cdot |\dot{m}_{in}|}{\pi \cdot D \cdot \frac{\eta_{in}+\eta_{out}}{2}}\\ \eta: \text{dynamic viscosity}\\ v: \text{specific volume}\\ \lambda: \text{darcy friction factor}\end{split}\end{aligned}\end{align} \]

darcy_func_doc(label)[source]#

Equation for pressure drop calculation from darcy friction factor.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Equation for pressure drop calculation.

Returns:

residual (float) – Residual value of equation:

\[0 =\dot{m}_{in}\cdot\left( h_{out}-h_{in}\right) -\dot{Q}\]

energy_balance_func_doc(label)[source]#

Equation for pressure drop calculation.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of a simple heat exchanger.

The allocation of the entropy streams due to heat exchanged and due to irreversibility is performed by solving for T:

\[h_\mathrm{out} - h_\mathrm{in} = \int_\mathrm{out}^\mathrm{in} v \cdot dp - \int_\mathrm{out}^\mathrm{in} T \cdot ds\]

As solving \(\int_\mathrm{out}^\mathrm{in} v \cdot dp\) for non isobaric processes would require perfect process knowledge (the path) on how specific volume and pressure change throught the component, the heat transfer is splitted into three separate virtual processes:

  • in->in*: decrease pressure to \(p_\mathrm{in*}=p_\mathrm{in}\cdot\sqrt{\frac{p_\mathrm{out}}{p_\mathrm{in}}}\) without changing enthalpy.

  • in*->out* transfer heat without changing pressure. \(h_\mathrm{out*}-h_\mathrm{in*}=h_\mathrm{out}-h_\mathrm{in}\)

  • out*->out decrease pressure to outlet pressure \(p_\mathrm{out}\) without changing enthalpy.

Note

The entropy balance makes the follwing parameter available:

\[\begin{split}\text{S\_Q}=\dot{m} \cdot \left(s_\mathrm{out*}-s_\mathrm{in*} \right)\\ \text{S\_irr}=\dot{m} \cdot \left(s_\mathrm{out}-s_\mathrm{in} \right) - \text{S\_Q}\\ \text{T\_mQ}=\frac{\dot{Q}}{\text{S\_Q}}\end{split}\]
exergy_balance(T0)[source]#

Calculate exergy balance of a simple heat exchanger.

The exergy of heat is calculated by allocation of thermal and mechanical share of exergy in the physical exergy. Depending on the temperature levels at the inlet and outlet of the heat exchanger as well as the direction of heat transfer (input or output) fuel and product exergy are calculated as follows.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

If the fluid transfers heat to the ambient, you can specify mysimpleheatexchanger.set_attr(dissipative=False) if you do NOT want the exergy production nan (only applicable in case \(\dot{Q}<0\)).

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \begin{cases} \begin{cases} \text{not defined (nan)} & \text{if dissipative}\\ \dot{E}_\mathrm{in}^\mathrm{T} - \dot{E}_\mathrm{out}^\mathrm{T} & \text{else}\\ \end{cases} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{out}^\mathrm{T} & T_\mathrm{in} \geq T_0 > T_\mathrm{out}\\ \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{in}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases} & \dot{Q} < 0\\\end{split}\\\begin{split}\begin{cases} \dot{E}_\mathrm{out}^\mathrm{PH} - \dot{E}_\mathrm{in}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{out}^\mathrm{T} & T_\mathrm{out} > T_0 \geq T_\mathrm{in}\\ \dot{E}_\mathrm{in}^\mathrm{T} - \dot{E}_\mathrm{out}^\mathrm{T} + \dot{E}_\mathrm{out}^\mathrm{M} - \dot{E}_\mathrm{in}^\mathrm{M} + & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases} & \dot{Q} > 0\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \begin{cases} \dot{E}_\mathrm{in}^\mathrm{PH} - \dot{E}_\mathrm{out}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M} + \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{out}^\mathrm{M} & T_\mathrm{in} \geq T_0 > T_\mathrm{out}\\ \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} + & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases} & \dot{Q} < 0\\\end{split}\\\begin{split}\begin{cases} \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{in}^\mathrm{T} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_\mathrm{out} > T_0 \geq T_\mathrm{in}\\ \dot{E}_\mathrm{in}^\mathrm{T}-\dot{E}_\mathrm{out}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases} & \dot{Q} > 0\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{bus} = \begin{cases} \begin{cases} \dot{E}_\mathrm{P} & \text{other cases}\\ \dot{E}_\mathrm{in}^\mathrm{T} & T_\mathrm{in} \geq T_0 > T_\mathrm{out}\\ \end{cases} & \dot{Q} < 0\\ \dot{E}_\mathrm{F} & \dot{Q} > 0\\ \end{cases}\end{split}\end{aligned}\end{align} \]
get_parameters()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

hazen_williams_deriv(increment_filter, k)[source]#

Calculate partial derivatives of hydro group (pressure drop).

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

hazen_williams_func()[source]#

Equation for pressure drop calculation from Hazen-Williams equation.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \left(p_{in} - p_{out} \right) \cdot \left(-1\right)^i - \frac{10.67 \cdot |\dot{m}_{in}| ^ {1.852} \cdot L}{ks^{1.852} \cdot D^{4.871}} \cdot g \cdot \left(\frac{v_{in} + v_{out}}{2}\right)^{0.852}\\\begin{split}i = \begin{cases} 0 & \dot{m}_{in} \geq 0\\ 1 & \dot{m}_{in} < 0 \end{cases}\end{split}\end{aligned}\end{align} \]

Note

Gravity \(g\) is set to \(9.81 \frac{m}{s^2}\)

hazen_williams_func_doc(label)[source]#

Equation for pressure drop calculation from Hazen-Williams equation.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy the outlets.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} \begin{cases} 1 \cdot 10^5 \; \frac{\text{J}}{\text{kg}} & \dot{Q} < 0\\ 3 \cdot 10^5 \; \frac{\text{J}}{\text{kg}} & \dot{Q} = 0\\ 5 \cdot 10^5 \; \frac{\text{J}}{\text{kg}} & \dot{Q} > 0 \end{cases} & \text{key = 'h'}\\ \; \; \; \; 10^5 \text{Pa} & \text{key = 'p'} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy the inlets.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 1 \cdot 10^5 & \text{key = 'p'}\\ \begin{cases} 5 \cdot 10^5 & \dot{Q} < 0\\ 3 \cdot 10^5 & \dot{Q} = 0\\ 1 \cdot 10^5 & \dot{Q} > 0 \end{cases} & \text{key = 'h'}\\ \end{cases}\end{split}\]

static inlets()[source]#
kA_char_group_deriv(increment_filter, k)[source]#

Calculate partial derivatives of kA characteristics.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

kA_char_group_func()[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \dot{m}_{in} \cdot \left( h_{out} - h_{in}\right) + kA_{design} \cdot f_{kA} \cdot \Delta T_{log}\\\begin{split}\Delta T_{log} = \begin{cases} \frac{T_{in}-T_{out}}{\ln{\frac{T_{in}-T_{amb}} {T_{out}-T_{amb}}}} & T_{in} > T_{out} \\ \frac{T_{out}-T_{in}}{\ln{\frac{T_{out}-T_{amb}} {T_{in}-T_{amb}}}} & T_{in} < T_{out}\\ 0 & T_{in} = T_{out} \end{cases}\end{split}\\f_{kA} = \frac{2}{1 + \frac{1}{f\left( expr\right)}}\\T_{amb}: \text{ambient temperature}\end{aligned}\end{align} \]

Note

For standard function of fkA see module tespy.data.

kA_char_group_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

kA_group_deriv(increment_filter, k)[source]#

Calculate partial derivatives of kA group.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

kA_group_func()[source]#

Calculate heat transfer from heat transfer coefficient.

Returns:

residual (float) – Residual value of equation.

\[ \begin{align}\begin{aligned}0 = \dot{m}_{in} \cdot \left( h_{out} - h_{in}\right) + kA \cdot \Delta T_{log}\\\begin{split}\Delta T_{log} = \begin{cases} \frac{T_{in}-T_{out}}{\ln{\frac{T_{in}-T_{amb}} {T_{out}-T_{amb}}}} & T_{in} > T_{out} \\ \frac{T_{out}-T_{in}}{\ln{\frac{T_{out}-T_{amb}} {T_{in}-T_{amb}}}} & T_{in} < T_{out}\\ 0 & T_{in} = T_{out} \end{cases}\end{split}\\T_{amb}: \text{ambient temperature}\end{aligned}\end{align} \]

kA_group_func_doc(label)[source]#

Calculate heat transfer from heat transfer coefficient.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

tespy.components.heat_exchangers.parabolic_trough module#

Module of class ParabolicTrough.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/parabolic_trough.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.parabolic_trough.ParabolicTrough(label, **kwargs)[source]#

Bases: SimpleHeatExchanger

The ParabolicTrough calculates heat output from irradiance.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the parabolic troughflowsheet of the parabolic trough
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict, "var") – Heat transfer, \(Q/\text{W}\).

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • D (float, dict, "var") – Diameter of the absorber tube, \(D/\text{m}\).

  • L (float, dict, "var") – Length of the absorber tube, \(L/\text{m}\).

  • ks (float, dict, "var") – Pipe’s roughness, \(ks/\text{m}\).

  • darcy_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using darcy weissbach equation.

  • ks_HW (float, dict, "var") – Pipe’s roughness, \(ks/\text{1}\).

  • hw_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using hazen williams equation.

  • E (float, dict, "var") – Direct irradiance to tilted collector, \(E/\frac{\text{W}}{\text{m}^2}\).

  • aoi (float, dict, "var") – Angle of incidience, \(aoi/^\circ\).

  • doc (float, dict, "var") – Degree of cleanliness (1: full absorption, 0: no absorption), \(X\).

  • eta_opt (float, dict, "var") – (constant) optical losses due to surface reflection, \(\eta_{opt}\).

  • c_1 (float, dict, "var") – Linear thermal loss key figure, \(c_1/\frac{\text{W}}{\text{K} \cdot \text{m}^2}\).

  • c_2 (float, dict, "var") – Quadratic thermal loss key figure, \(c_2/\frac{\text{W}}{\text{K}^2 \cdot \text{m}^2}\).

  • iam_1 (float, dict, "var") – Linear incidence angle modifier, \(iam_1/\frac{1}{^\circ}\).

  • iam_2 (float, dict, "var") – Quadratic incidence angle modifier, \(iam_2/\left(\frac{1}{^\circ}\right)^2\).

  • A (float, dict, "var") – Collector aperture surface area \(A/\text{m}^2\).

  • Tamb (float, dict) – Ambient temperature, provide parameter in network’s temperature unit.

  • energy_group (str, dict) – Parametergroup for energy balance of solarthermal collector.

Example

A parabolic trough is installed using S800 as thermo-fluid. First, the operation conditions from [21] are reproduced. Therefore, the direct normal irradiance \(\dot{E}_\mathrm{DNI}\) is at 1000 \(\frac{\text{W}}{\text{m}^2}\) at an angle of incidence \(aoi\) at 20 °. This means, the direct irradiance to the parabolic trough \(E\) is at \(\dot{E}_{DNI} \cdot cos\left(20^\circ\right)\).

>>> from tespy.components import Sink, Source, ParabolicTrough
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import numpy as np
>>> import shutil
>>> nw = Network()
>>> nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> pt = ParabolicTrough('parabolic trough collector')
>>> pt.component()
'parabolic trough'
>>> inc = Connection(so, 'out1', pt, 'in1')
>>> outg = Connection(pt, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)

The pressure ratio is at a constant level of 1. However, it is possible to specify the pressure losses from the absorber tube length, roughness and diameter, too. The aperture surface \(A\) is specified to 1 \(\text{m}^2\) for simplicity reasons.

>>> aoi = 20
>>> E = 1000 * np.cos(aoi / 180 * np.pi)
>>> pt.set_attr(pr=1, aoi=aoi, doc=1,
... Tamb=20, A=1, eta_opt=0.816, c_1=0.0622, c_2=0.00023, E=E,
... iam_1=-1.59e-3, iam_2=9.77e-5)
>>> inc.set_attr(fluid={'INCOMP::S800': 1}, T=220, p=2)
>>> outg.set_attr(T=260)
>>> nw.solve('design')
>>> round(pt.Q.val, 0)
736.0

For example, it is possible to calculate the aperture area of the parabolic trough given the total heat production, outflow temperature and mass flow.

>>> pt.set_attr(A='var', Q=5e6, Tamb=25)
>>> inc.set_attr(T=None)
>>> outg.set_attr(T=350, m=20)
>>> nw.solve('design')
>>> round(inc.T.val, 0)
229.0
>>> round(pt.A.val, 0)
6862.0

Given this design, it is possible to calculate the outlet temperature as well as the heat transfer at different operating points.

>>> aoi = 30
>>> E = 800 * np.cos(aoi / 180 * np.pi)
>>> pt.set_attr(A=pt.A.val, aoi=aoi, Q=None, E=E)
>>> inc.set_attr(T=150)
>>> outg.set_attr(T=None)
>>> nw.solve('design')
>>> round(outg.T.val, 0)
244.0
>>> round(pt.Q.val, 0)
3603027.0
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_group_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy group function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_group_func()[source]#

Equation for solar collector energy balance.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} T_m = & \frac{T_{out} + T_{in}}{2}\\ iam = & 1 - iam_1 \cdot |aoi| - iam_2 \cdot aoi^2\\ 0 = & \dot{m} \cdot \left( h_{out} - h_{in} \right)\\ & - A \cdot \left[E \cdot \eta_{opt} \cdot doc^{1.5} \cdot iam \right. \\ & \left. - c_1 \cdot \left(T_m - T_{amb} \right) - c_2 \cdot \left(T_m - T_{amb}\right)^2 \vphantom{ \eta_{opt} \cdot doc^{1.5}} \right] \end{split}\end{split}\]

Reference: [21].

energy_group_func_doc(label)[source]#

Equation for solar collector energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_parameters()[source]#

tespy.components.heat_exchangers.solar_collector module#

Module of class SolarCollector.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/heat_exchangers/solar_collector.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.solar_collector.SolarCollector(label, **kwargs)[source]#

Bases: SimpleHeatExchanger

The solar collector calculates heat output from irradiance.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the solar collectorflowsheet of the solar collector
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict, "var") – Heat transfer, \(Q/\text{W}\).

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • D (float, dict, "var") – Diameter of the pipes, \(D/\text{m}\).

  • L (float, dict, "var") – Length of the pipes, \(L/\text{m}\).

  • ks (float, dict, "var") – Pipe’s roughness, \(ks/\text{m}\).

  • darcy_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using darcy weissbach equation.

  • ks_HW (float, dict, "var") – Pipe’s roughness, \(ks/\text{1}\).

  • hw_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using hazen williams equation.

  • E (float, dict, "var") – irradiance at tilted collector surface area, \(E/\frac{\text{W}}{\text{m}^2}\).

  • eta_opt (float, dict, "var") – optical loss at surface cover, \(\eta_{opt}\).

  • lkf_lin (float, dict, "var") – Linear thermal loss key figure, \(\alpha_1/\frac{\text{W}}{\text{K} \cdot \text{m}^2}\).

  • lkf_quad (float, dict, "var") – Quadratic thermal loss key figure, \(\alpha_2/\frac{\text{W}}{\text{K}^2 \cdot \text{m}^2}\).

  • A (float, dict, "var") – Collector surface area \(A/\text{m}^2\).

  • Tamb (float, dict) – Ambient temperature, provide parameter in network’s temperature unit.

  • energy_group (str, dict) – Parametergroup for energy balance of solarthermal collector.

Example

The solar collector is used to calculate heat transferred to the heating system from irradiance on a tilted plane. For instance, it is possible to calculate the collector surface area required to transfer a specific amount of heat at a given irradiance. The collector parameters are the linear and the quadratic loss keyfigure as well as the optical effifiency.

>>> from tespy.components import Sink, Source, SolarCollector
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network()
>>> nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> sc = SolarCollector('solar collector')
>>> sc.component()
'solar collector'
>>> sc.set_attr(pr=0.95, Q=1e4, design=['pr', 'Q'], offdesign=['zeta'],
...     Tamb=25, A='var', eta_opt=0.92, lkf_lin=1, lkf_quad=0.005, E=8e2)
>>> inc = Connection(so, 'out1', sc, 'in1')
>>> outg = Connection(sc, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)

The outlet temperature should be at 90 °C at a constant mass flow, which is determined in the design calculation. In offdesign operation (at a different irradiance) using the calculated surface area and mass flow, it is possible to predict the outlet temperature. It would instead be possible to calulate the change in mass flow required to hold the specified outlet temperature, too.

>>> inc.set_attr(fluid={'H2O': 1}, T=40, p=3, offdesign=['m'])
>>> outg.set_attr(T=90, design=['T'])
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(sc.A.val, 1)
14.5
>>> sc.set_attr(A=sc.A.val, E=5e2, Tamb=20)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(sc.Q.val, 1)
6083.8
>>> round(outg.T.val, 1)
70.5
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_group_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy group function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_group_func()[source]#

Equation for solar collector energy balance.

Returns:

residual (float) – Residual value of equation.

\[\begin{split}\begin{split} 0 = & \dot{m} \cdot \left( h_{out} - h_{in} \right)\\ & - A \cdot \left[E \cdot \eta_{opt} - \alpha_1 \cdot \left(T_m - T_{amb} \right) - \alpha_2 \cdot \left(T_m - T_{amb}\right)^2 \right]\\ T_m = & \frac{T_{out} + T_{in}}{2}\\ \end{split}\end{split}\]

Reference: [22].

energy_group_func_doc(label)[source]#

Equation for solar collector energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_parameters()[source]#

tespy.components.nodes.base module#

Module of class NodeBase.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/base.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.base.NodeBase(label, **kwargs)[source]#

Bases: Component

Class NodeBase is parent class for all components of submodule nodes.

static initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

mass_flow_deriv(k)[source]#

Calculate partial derivatives for mass flow equation.

Returns:

deriv (list) – Matrix with partial derivatives for the fluid equations.

mass_flow_func()[source]#

Calculate the residual value for mass flow balance equation.

Returns:

res (float) – Residual value of equation.

\[0 = \sum \dot{m}_{in,i} - \sum \dot{m}_{out,j} \; \forall i \in inlets, \forall j \in outlets\]

mass_flow_func_doc(label)[source]#

Calculate the residual value for mass flow balance equation.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

pressure_equality_deriv(k)[source]#

Calculate partial derivatives for all pressure equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the fluid equations.

pressure_equality_func()[source]#

Calculate the residual values of pressure equality equations.

Returns:

residual (list) – Vector with residual value for pressure equality equations.

\[\begin{split}0 = p_{in,1} - p_{in,i}\forall i \in \text{inlets > 1}\\ 0 = p_{in,1} - p_{out,j}\forall j \in \text{outlets}\end{split}\]

pressure_equality_func_doc(label)[source]#

Calculate the residual values of pressure equality equations.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

propagate_to_target(branch)[source]#

tespy.components.nodes.droplet_separator module#

Module of class DropletSeparator.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/droplet_separator.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.droplet_separator.DropletSeparator(label, **kwargs)[source]#

Bases: NodeBase

Separate liquid phase from gas phase of a single fluid.

This component is the parent component of the Drum.

Mandatory Equations

Inlets/Outlets

  • in1

  • out1, out2 (index 1: saturated liquid, index 2: saturated gas)

Image

flowsheet of the droplet separatorflowsheet of the droplet separator
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

Example

The droplet separator separates gas from liquid phase. From a stream of water the liquid phase will be separated.

>>> from tespy.components import Sink, Source, DropletSeparator
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', h_unit='kJ / kg', iterinfo=False)
>>> so = Source('two phase inflow')
>>> sig = Sink('gas outflow')
>>> sil = Sink('liquid outflow')
>>> ds = DropletSeparator('droplet separator')
>>> ds.component()
'droplet separator'
>>> so_ds = Connection(so, 'out1', ds, 'in1')
>>> ds_sig = Connection(ds, 'out2', sig, 'in1')
>>> ds_sil = Connection(ds, 'out1', sil, 'in1')
>>> nw.add_conns(so_ds, ds_sig, ds_sil)

We specify the fluid’s state at the inlet. At the gas outflow saturated gas enthalpy is expected, at the liquid gas outflow saturated liquid enthalpy. The mass flow at the outlets is expected to split according to the vapor mass fraction:

\[ \begin{align}\begin{aligned}\dot{m}_\mathrm{out,1} = \left(1 - \frac{h_\mathrm{in} - h'}{h'' - h'} \right) \cdot \dot{m}_\mathrm{in}\\\dot{m}_\mathrm{out,2} = \frac{h_\mathrm{in} - h'}{h'' - h'} \cdot \dot{m}_\mathrm{in}\end{aligned}\end{align} \]
>>> so_ds.set_attr(fluid={'water': 1}, p=1, h=1500, m=10)
>>> nw.solve('design')
>>> Q_in = so_ds.calc_Q()
>>> round(Q_in * so_ds.m.val_SI, 6) == round(ds_sig.m.val_SI, 6)
True
>>> round((1 - Q_in) * so_ds.m.val_SI, 6) == round(ds_sil.m.val_SI, 6)
True
>>> ds_sig.calc_Q()
1.0
>>> ds_sil.calc_Q()
0.0

In a different setup, we unset pressure and enthalpy and specify gas temperature and mass flow instead. The temperature specification must yield the corresponding boiling point pressure and the mass flow must yield the inlet enthalpy. The inlet vapor mass fraction must be equal to fraction of gas mass flow to inlet mass flow (0.95 in this example).

>>> so_ds.set_attr(fluid={'water': 1}, p=None, h=None, T=150, m=10)
>>> ds_sig.set_attr(m=9.5)
>>> nw.solve('design')
>>> round(so_ds.calc_Q(), 6)
0.95
>>> T_boil = so_ds.calc_T_sat()
>>> round(T_boil, 6) == round(so_ds.T.val_SI, 6)
True
static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate energy balance.

Returns:

residual (float) – Residual value of energy balance.

\[\begin{split}0 = \sum_i \left(\dot{m}_{in,i} \cdot h_{in,i} \right) - \sum_j \left(\dot{m}_{out,j} \cdot h_{out,j} \right)\\ \forall i \in \text{inlets} \; \forall j \in \text{outlets}\end{split}\]

energy_balance_func_doc(label)[source]#

Calculate energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_mandatory_constraints()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

static initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^6 & \text{key = 'p'}\\ h\left(p, x=1 \right) & \text{key = 'h' at outlet 1}\\ h\left(p, x=0 \right) & \text{key = 'h' at outlet 2} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^6 & \text{key = 'p'}\\ h\left(p, x=0.5 \right) & \text{key = 'h' at inlet 1} \end{cases}\end{split}\]

static inlets()[source]#
outlet_states_deriv(increment_filter, k)[source]#

Calculate partial derivatives of outlet states.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

outlet_states_func()[source]#

Calculate energy balance.

Returns:

residual (list) – Residual values of outlet state equations.

\[\begin{split}0 = h_{out,1} - h\left(p, x=0 \right)\\ 0 = h_{out,2} - h\left(p, x=1 \right)\end{split}\]

outlet_states_func_doc(label)[source]#

Calculate energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
propagate_wrapper_to_target(branch)[source]#

tespy.components.nodes.drum module#

Module of class Drum.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/drum.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.drum.Drum(label, **kwargs)[source]#

Bases: DropletSeparator

A drum separates saturated gas from saturated liquid.

Mandatory Equations

Inlets/Outlets

  • in1, in2 (index 1: from economiser, index 2: from evaporator)

  • out1, out2 (index 1: saturated liquid, index 2: saturated gas)

Image

flowsheet of the drumflowsheet of the drum
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

Note

If you are using a drum in a network with multiple fluids, it is likely the fluid propagation causes trouble. If this is the case, try to specify the fluid composition at another connection of your network.

This component assumes, that the fluid composition between outlet 1 and inlet 2 does not change, thus there is no equation for the fluid mass fraction at the inlet 2!

Example

The drum separates saturated gas from saturated liquid. The liquid phase is transported to an evaporator, the staturated gas phase is extracted from the drum. In this example ammonia is evaporated using ambient air. A characteristic function is applied for the heat transfer coefficient of the evaporator. It is possible to load the CharLine with the function load_default_char from the default lines. We want to use the ‘EVAPORATING FLUID’ lines of the heat exchanger.

>>> from tespy.components import Sink, Source, Drum, Pump, HeatExchanger
>>> from tespy.connections import Connection, Ref
>>> from tespy.networks import Network
>>> from tespy.tools.characteristics import CharLine
>>> from tespy.tools.characteristics import load_default_char as ldc
>>> import shutil
>>> import numpy as np
>>> nw = Network(T_unit='C', p_unit='bar', h_unit='kJ / kg', iterinfo=False)
>>> fa = Source('feed ammonia')
>>> amb_in = Source('air inlet')
>>> amb_out = Sink('air outlet')
>>> s = Sink('steam')
>>> dr = Drum('drum')
>>> dr.component()
'drum'
>>> ev = HeatExchanger('evaporator')
>>> erp = Pump('evaporator reciculation pump')
>>> f_dr = Connection(fa, 'out1', dr, 'in1')
>>> dr_erp = Connection(dr, 'out1', erp, 'in1')
>>> erp_ev = Connection(erp, 'out1', ev, 'in2')
>>> ev_dr = Connection(ev, 'out2', dr, 'in2')
>>> dr_s = Connection(dr, 'out2', s, 'in1')
>>> nw.add_conns(f_dr, dr_erp, erp_ev, ev_dr, dr_s)
>>> amb_ev = Connection(amb_in, 'out1', ev, 'in1')
>>> ev_amb = Connection(ev, 'out1', amb_out, 'in1')
>>> nw.add_conns(amb_ev, ev_amb)

The ambient air enters the evaporator at 30 °C. The pinch point temperature difference (ttd_l) of the evaporator is at 5 K, and 1 MW of heat should be transferred. State of ammonia at the inlet is at -5 °C and 5 bar. From this design it is possible to calculate offdesign performance at 75 % part load.

>>> char1 = ldc('heat exchanger', 'kA_char1', 'DEFAULT',
... CharLine)
>>> char2 = ldc('heat exchanger', 'kA_char2', 'EVAPORATING FLUID',
... CharLine)
>>> ev.set_attr(pr1=0.999, pr2=0.99, ttd_l=5, kA_char1=char1,
...     kA_char2=char2, design=['pr1', 'ttd_l'],
...     offdesign=['zeta1', 'kA_char'])
>>> ev.set_attr(Q=-1e6)
>>> erp.set_attr(eta_s=0.8)
>>> f_dr.set_attr(p=5, T=-5)
>>> erp_ev.set_attr(m=Ref(f_dr, 4, 0), fluid={'NH3': 1})
>>> amb_ev.set_attr(fluid={'air': 1}, T=30)
>>> ev_amb.set_attr(p=1)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(ev_amb.T.val - erp_ev.T.val ,1)
5.0
>>> round(f_dr.h.val, 1)
322.7
>>> round(dr_erp.h.val, 1)
364.9
>>> round(ev_dr.h.val, 1)
687.2
>>> round(f_dr.m.val, 2)
0.78
>>> ev.set_attr(Q=-0.75e6)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(f_dr.m.val, 2)
0.58
>>> round(ev_amb.T.val - erp_ev.T.val ,1)
3.0
>>> shutil.rmtree('./tmp', ignore_errors=True)
static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate energy balance.

Returns:

residual (float) – Residual value of energy balance.

\[\begin{split}0 = \sum_i \left(\dot{m}_{in,i} \cdot h_{in,i} \right) - \sum_j \left(\dot{m}_{out,j} \cdot h_{out,j} \right)\\ \forall i \in \text{inlets} \; \forall j \in \text{outlets}\end{split}\]

exergy_balance(T0)[source]#

Calculate exergy balance of a merge.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

Please note, that the exergy balance accounts for physical exergy only.

\[\begin{split}\dot{E}_\mathrm{P} = \sum \dot{E}_{\mathrm{out,}j}^\mathrm{PH}\\ \dot{E}_\mathrm{F} = \sum \dot{E}_{\mathrm{in,}i}^\mathrm{PH}\end{split}\]
get_mandatory_constraints()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^6 & \text{key = 'p'}\\ h\left(p, x=0 \right) & \text{key = 'h' at inlet 1}\\ h\left(p, x=0.7 \right) & \text{key = 'h' at inlet 2} \end{cases}\end{split}\]

static inlets()[source]#
mass_flow_deriv(k)[source]#

Calculate partial derivatives for mass flow equation.

Returns:

deriv (list) – Matrix with partial derivatives for the fluid equations.

mass_flow_func()[source]#

Calculate the residual value for mass flow balance equation.

Returns:

res (float) – Residual value of equation.

\[0 = \sum \dot{m}_{in,i} - \sum \dot{m}_{out,j} \; \forall i \in inlets, \forall j \in outlets\]

static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#

tespy.components.nodes.merge module#

Module of class Merge.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/merge.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.merge.Merge(label, **kwargs)[source]#

Bases: NodeBase

Class for merge points with multiple inflows and one outflow.

Mandatory Equations

Inlets/Outlets

  • specify number of outlets with num_in (default value: 2)

  • out1

Image

flowsheet of the mergeflowsheet of the merge
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • num_in (float, dict) – Number of inlets for this component, default value: 2.

Example

The merge mixes a specified number of mass flows and has a single outlet. At the outlet, fluid composition and enthalpy are calculated by mass weighted fluid composition and enthalpy of the inlets.

>>> from tespy.components import Sink, Source, Merge
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> import numpy as np
>>> nw = Network(p_unit='bar', iterinfo=False)
>>> so1 = Source('source1')
>>> so2 = Source('source2')
>>> so3 = Source('source3')
>>> si1 = Sink('sink')
>>> m = Merge('merge', num_in=3)
>>> m.component()
'merge'
>>> inc1 = Connection(so1, 'out1', m, 'in1')
>>> inc2 = Connection(so2, 'out1', m, 'in2')
>>> inc3 = Connection(so3, 'out1', m, 'in3')
>>> outg = Connection(m, 'out1', si1, 'in1')
>>> nw.add_conns(inc1, inc2, inc3, outg)

A merge with three inlets mixes air (simplified) with pure nitrogen and pure oxygen. All gases enter the component at the same temperature. As mixing effects are not considered, the outlet temperature should thus be similar to the three inlet temperatures (difference might occur due to rounding in fluid property functions, let’s check it for two different temperatures). It is e.g. possible to find the required mass flow of pure nitrogen given the nitrogen mass fraction in the outlet.

>>> T = 293.15
>>> inc1.set_attr(fluid={'O2': 0.23, 'N2': 0.77}, p=1, T=T, m=5)
>>> inc2.set_attr(fluid={'O2': 1}, T=T, m=5)
>>> inc3.set_attr(fluid={'N2': 1}, T=T)
>>> outg.set_attr(fluid={'N2': 0.4})
>>> nw.solve('design')
>>> round(inc3.m.val_SI, 2)
0.25
>>> abs(round((outg.T.val_SI - T) / T, 5)) < 0.01
True
>>> T = 173.15
>>> inc1.set_attr(T=T)
>>> inc2.set_attr(T=T)
>>> inc3.set_attr(T=T)
>>> nw.solve('design')
>>> abs(round((outg.T.val_SI - T) / T, 5)) < 0.01
True
static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate energy balance.

Returns:

residual (float) – Residual value of energy balance.

\[\begin{split}0 = \sum_i \left(\dot{m}_{in,i} \cdot h_{in,i} \right) - \dot{m}_{out} \cdot h_{out}\\ \forall i \in \text{inlets}\end{split}\]

energy_balance_func_doc(label)[source]#

Calculate energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of a merge.

Note

A definition of reference points is included for compensation of differences in zero point definitions of different fluid compositions.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

\[\begin{split}\dot{S}_\mathrm{irr}= \dot{m}_\mathrm{out} \cdot \left( s_\mathrm{out} - s_\mathrm{out,ref} \right) - \sum_{i} \dot{m}_{\mathrm{in,}i} \cdot \left( s_{\mathrm{in,}i} - s_{\mathrm{in,ref,}i} \right)\\\end{split}\]
exergy_balance(T0)[source]#

Calculate exergy balance of a merge.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

Please note, that the exergy balance accounts for physical exergy only.

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \begin{cases} \sum_i \dot{m}_i \cdot \left(e_\mathrm{out}^\mathrm{PH} - e_{\mathrm{in,}i}^\mathrm{PH}\right) & T_{\mathrm{in,}i} < T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} \geq T_0 \\ \sum_i \dot{m}_i \cdot e_\mathrm{out}^\mathrm{PH} & T_{\mathrm{in,}i} < T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} < T_0 \\ \end{cases} & T_\mathrm{out} > T_0\\\end{split}\\\begin{split}\text{not defined (nan)} & T_\mathrm{out} = T_0\\\end{split}\\\begin{split}\begin{cases} \sum_i \dot{m}_i \cdot e_\mathrm{out}^\mathrm{PH} & T_{\mathrm{in,}i} > T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} \geq T_0 \\ \sum_i \dot{m}_i \cdot \left(e_\mathrm{out}^\mathrm{PH} - e_{\mathrm{in,}i}^\mathrm{PH}\right) & T_{\mathrm{in,}i} > T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} < T_0 \\ \end{cases} & T_\mathrm{out} < T_0\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \begin{cases} \sum_i \dot{m}_i \cdot \left(e_{\mathrm{in,}i}^\mathrm{PH} - e_\mathrm{out}^\mathrm{PH}\right) & T_{\mathrm{in,}i} > T_\mathrm{out} \\ \sum_i \dot{E}_{\mathrm{in,}i}^\mathrm{PH} & T_{\mathrm{in,}i} < T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} < T_0 \\ \end{cases} & T_\mathrm{out} > T_0\\\end{split}\\\begin{split}\sum_i \dot{E}_{\mathrm{in,}i}^\mathrm{PH} & T_\mathrm{out} = T_0\\\end{split}\\\begin{split}\begin{cases} \sum_i \dot{E}_{\mathrm{in,}i}^\mathrm{PH} & T_{\mathrm{in,}i} > T_\mathrm{out} \text{ \& } T_{\mathrm{in,}i} \geq T_0 \\ \sum_i \dot{m}_i \cdot \left(e_{\mathrm{in,}i}^\mathrm{PH} - e_\mathrm{out}^\mathrm{PH}\right) & T_{\mathrm{in,}i} < T_\mathrm{out} \\ \end{cases} & T_\mathrm{out} < T_0\\ \end{cases}\end{split}\\\forall i \in \text{merge inlets}\\\dot{E}_\mathrm{bus} = \text{not defined (nan)}\end{aligned}\end{align} \]
fluid_deriv(increment_filter, k)[source]#

Calculate partial derivatives of fluid balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

fluid_func()[source]#

Calculate the vector of residual values for fluid balance equations.

Returns:

residual (list) – Vector of residual values for component’s fluid balance.

\[\begin{split}0 = \sum_i \dot{m}_{in,i} \cdot x_{fl,in,i} - \dot {m}_{out} \cdot x_{fl,out}\\ \forall fl \in \text{network fluids}, \; \forall i \in \text{inlets}\end{split}\]

fluid_func_doc(label)[source]#

Calculate the vector of residual values for fluid balance equations.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_mandatory_constraints()[source]#
static get_parameters()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

inlets()[source]#
static is_branch_source()[source]#
static outlets()[source]#
propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
start_branch()[source]#

tespy.components.nodes.separator module#

Module of class Separator.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/separator.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.separator.Separator(label, **kwargs)[source]#

Bases: NodeBase

A separator separates fluid components from a mass flow.

Mandatory Equations

Inlets/Outlets

  • in1

  • specify number of outlets with num_out (default value: 2)

Image

flowsheet of the splitterflowsheet of the splitter

Note

Fluid separation requires power and cooling, equations have not been implemented, yet!

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • num_out (float, dict) – Number of outlets for this component, default value: 2.

Example

The separator is used to split up a single mass flow into a specified number of different parts at identical pressure and temperature but different fluid composition. Fluids can be separated from each other.

>>> from tespy.components import Sink, Source, Separator
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> import numpy as np
>>> nw = Network(p_unit='bar', T_unit='C',
... iterinfo=False)
>>> so = Source('source')
>>> si1 = Sink('sink1')
>>> si2 = Sink('sink2')
>>> s = Separator('separator', num_out=2)
>>> s.component()
'separator'
>>> inc = Connection(so, 'out1', s, 'in1')
>>> outg1 = Connection(s, 'out1', si1, 'in1')
>>> outg2 = Connection(s, 'out2', si2, 'in1')
>>> nw.add_conns(inc, outg1, outg2)

An Air (simplified) mass flow of 5 kg/s is split up into two mass flows. One mass flow of 1 kg/s containing 10 % oxygen and 90 % nitrogen leaves the separator. It is possible to calculate the fluid composition of the second mass flow. Specify starting values for the second mass flow fluid composition for calculation stability.

>>> inc.set_attr(fluid={'O2': 0.23, 'N2': 0.77}, p=1, T=20, m=5)
>>> outg1.set_attr(fluid={'O2': 0.1, 'N2': 0.9}, m=1)
>>> outg2.set_attr(fluid0={'O2': 0.5, 'N2': 0.5})
>>> nw.solve('design')
>>> outg2.fluid.val['O2']
0.2625

In the same way, it is possible to specify one of the fluid components in the second mass flow instead of the first mass flow. The solver will find the mass flows matching the desired composition. 65 % of the mass flow will leave the separator at the second outlet the case of 30 % oxygen mass fraction for this outlet.

>>> outg1.set_attr(m=None)
>>> outg2.set_attr(fluid={'O2': 0.3})
>>> nw.solve('design')
>>> outg2.fluid.val['O2']
0.3
>>> round(outg2.m.val_SI / inc.m.val_SI, 2)
0.65
static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate energy balance.

Returns:

residual (list) – Residual value of energy balance.

\[\begin{split}0 = T_{in} - T_{out,j}\\ \forall j \in \text{outlets}\end{split}\]

energy_balance_func_doc(label)[source]#

Calculate energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

fluid_deriv(increment_filter, k)[source]#

Calculate partial derivatives of fluid balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

fluid_func()[source]#

Calculate the vector of residual values for fluid balance equations.

Returns:

residual (list) – Vector of residual values for component’s fluid balance.

\[\begin{split}0 = \dot{m}_{in} \cdot x_{fl,in} - \dot {m}_{out,j} \cdot x_{fl,out,j}\\ \forall fl \in \text{network fluids,} \; \forall j \in \text{outlets}\end{split}\]

fluid_func_doc(label)[source]#

Calculate the vector of residual values for fluid balance equations.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_mandatory_constraints()[source]#
static get_parameters()[source]#
static inlets()[source]#
static is_branch_source()[source]#
outlets()[source]#
propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
start_branch()[source]#

tespy.components.nodes.splitter module#

Module of class Splitter.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/nodes/splitter.py

SPDX-License-Identifier: MIT

class tespy.components.nodes.splitter.Splitter(label, **kwargs)[source]#

Bases: NodeBase

Split up a mass flow in parts of identical enthalpy and fluid composition.

Mandatory Equations

Inlets/Outlets

  • in1

  • specify number of outlets with num_out (default value: 2)

Image

flowsheet of the splitterflowsheet of the splitter
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • num_out (float, dict) – Number of outlets for this component, default value: 2.

Example

A splitter is used to split up a single mass flow into a specified number of different parts at identical pressure, enthalpy and fluid composition.

>>> from tespy.components import Sink, Source, Splitter
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> import numpy as np
>>> nw = Network(p_unit='bar', T_unit='C',
... iterinfo=False)
>>> so = Source('source')
>>> si1 = Sink('sink1')
>>> si2 = Sink('sink2')
>>> si3 = Sink('sink3')
>>> s = Splitter('splitter', num_out=3)
>>> s.component()
'splitter'
>>> inc = Connection(so, 'out1', s, 'in1')
>>> outg1 = Connection(s, 'out1', si1, 'in1')
>>> outg2 = Connection(s, 'out2', si2, 'in1')
>>> outg3 = Connection(s, 'out3', si3, 'in1')
>>> nw.add_conns(inc, outg1, outg2, outg3)

An Air (simplified) mass flow is split up into three mass flows. The total incoming mass flow is 5 kg/s, 3 kg/s and 1 kg/s respectively are leaving the splitter into the first two outlets. The residual mass flow will drain in the last outlet. Temperature and fluid composition will not change.

>>> inc.set_attr(fluid={'O2': 0.23, 'N2': 0.77}, p=1, T=20, m=5)
>>> outg1.set_attr(m=3)
>>> outg2.set_attr(m=1)
>>> nw.solve('design')
>>> round(outg3.m.val_SI, 1)
1.0
>>> round(inc.T.val, 1)
20.0
>>> round(outg3.T.val, 1)
20.0
static component()[source]#
energy_balance_deriv(k)[source]#

Calculate partial derivatives for energy balance equation.

Returns:

deriv (list) – Matrix of partial derivatives.

energy_balance_func()[source]#

Calculate energy balance.

Returns:

residual (list) – Residual value of energy balance.

\[\begin{split}0 = h_{in} - h_{out,j} \; \forall j \in \mathrm{outlets}\\\end{split}\]

energy_balance_func_doc(label)[source]#

Calculate energy balance.

Parameters:

label (str) – Label for equation.

get_mandatory_constraints()[source]#
static get_parameters()[source]#
static inlets()[source]#
outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_wrapper_to_target(branch)[source]#

tespy.components.piping.pipe module#

Module of class Pipe.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/piping/pipe.py

SPDX-License-Identifier: MIT

class tespy.components.piping.pipe.Pipe(label, **kwargs)[source]#

Bases: SimpleHeatExchanger

The Pipe is a subclass of a SimpleHeatExchanger.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the pipeflowsheet of the pipe
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • Q (float, dict, "var") – Heat transfer, \(Q/\text{W}\).

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • D (float, dict, "var") – Diameter of the pipes, \(D/\text{m}\).

  • L (float, dict, "var") – Length of the pipes, \(L/\text{m}\).

  • ks (float, dict, "var") – Pipe’s roughness, \(ks/\text{m}\).

  • darcy_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using darcy weissbach equation.

  • ks_HW (float, dict, "var") – Pipe’s roughness, \(ks/\text{1}\).

  • hw_group (str, dict) – Parametergroup for pressure drop calculation based on pipes dimensions using hazen williams equation.

  • kA (float, dict, "var") – Area independent heat transfer coefficient, \(kA/\frac{\text{W}}{\text{K}}\).

  • kA_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line for heat transfer coefficient.

  • Tamb (float, dict) – Ambient temperature, provide parameter in network’s temperature unit.

  • kA_group (str, dict) – Parametergroup for heat transfer calculation from ambient temperature and area independent heat transfer coefficient kA.

Example

A mass flow of 10 kg/s ethanol is transported in a pipeline. The pipe is considered adiabatic and has a length of 500 meters. We can calculate the diameter required at a given pressure loss of 2.5 %. After we determined the required diameter, we can predict pressure loss at a different mass flow through the pipeline.

>>> from tespy.components import Sink, Source, Pipe
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network()
>>> nw.set_attr(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> so = Source('source 1')
>>> si = Sink('sink 1')
>>> pi = Pipe('pipeline')
>>> pi.component()
'pipe'
>>> pi.set_attr(pr=0.975, Q=0, design=['pr'], L=100, D='var', ks=5e-5)
>>> inc = Connection(so, 'out1', pi, 'in1')
>>> outg = Connection(pi, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)
>>> inc.set_attr(fluid={'ethanol': 1}, m=10, T=30, p=3)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(pi.D.val, 3)
0.119
>>> outg.p.val / inc.p.val == pi.pr.val
True
>>> inc.set_attr(m=15)
>>> pi.set_attr(D=pi.D.val)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(pi.pr.val, 2)
0.94
>>> shutil.rmtree('./tmp', ignore_errors=True)
static component()[source]#

tespy.components.piping.valve module#

Module of class Valve.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/piping.py

SPDX-License-Identifier: MIT

class tespy.components.piping.valve.Valve(label, **kwargs)[source]#

Bases: Component

The Valve throttles a fluid without changing enthalpy.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the valveflowsheet of the valve
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\)

  • zeta (float, dict, "var") – Geometry independent friction coefficient, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

  • dp_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line for difference pressure to mass flow.

Example

A mass flow of 1 kg/s methane is throttled from 80 bar to 15 bar in a valve. The inlet temperature is at 50 °C. It is possible to determine the outlet temperature as the throttling does not change enthalpy.

>>> from tespy.components import Sink, Source, Valve
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> v = Valve('valve')
>>> v.component()
'valve'
>>> so_v = Connection(so, 'out1', v, 'in1')
>>> v_si = Connection(v, 'out1', si, 'in1')
>>> nw.add_conns(so_v, v_si)
>>> v.set_attr(offdesign=['zeta'])
>>> so_v.set_attr(fluid={'CH4': 1}, m=1, T=50, p=80, design=['m'])
>>> v_si.set_attr(p=15)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(v_si.T.val, 1)
26.3
>>> round(v.pr.val, 3)
0.188

The simulation determined the area independent zeta value \(\frac{\zeta}{D^4}\). This zeta remains constant if the cross sectional area of the valve opening does not change. Using the zeta value we can determine the pressure ratio at a different feed pressure.

>>> so_v.set_attr(p=70)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(so_v.m.val, 1)
0.9
>>> round(v_si.T.val, 1)
30.0
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
dp_char_deriv(increment_filter, k)[source]#

Calculate partial derivatives of difference pressure characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

dp_char_func()[source]#

Equation for characteristic line of difference pressure to mass flow.

Returns:

residual (ndarray) – Residual value of equation.

\[0=p_\mathrm{in}-p_\mathrm{out}-f\left( expr \right)\]

dp_char_func_doc(label)[source]#

Equation for characteristic line of difference pressure to mass flow.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of a valve.

Note

The entropy balance makes the follwing parameter available:

\[\begin{split}\text{S\_irr}=\dot{m} \cdot \left(s_\mathrm{out}-s_\mathrm{in} \right)\\\end{split}\]
exergy_balance(T0)[source]#

Calculate exergy balance of a valve.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \text{not defined (nan)} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{out}^\mathrm{T} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{E}_\mathrm{out}^\mathrm{T} - \dot{E}_\mathrm{in}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \dot{E}_\mathrm{in}^\mathrm{PH} - \dot{E}_\mathrm{out}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M}- \dot{E}_\mathrm{out}^\mathrm{M} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\end{aligned}\end{align} \]
get_mandatory_constraints()[source]#
get_parameters()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 4 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ 5 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static outlets()[source]#

tespy.components.reactors.fuel_cell module#

Module of class FuelCell.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/reactors/fuel_cell.py

SPDX-License-Identifier: MIT

class tespy.components.reactors.fuel_cell.FuelCell(label, **kwargs)[source]#

Bases: Component

The fuel cell produces power by oxidation of hydrogen.

Mandatory Equations

Optional Equations

Inlets/Outlets

  • in1 (cooling inlet), in2 (oxygen inlet), in3 (hydrogen inlet)

  • out1 (cooling outlet), out2 (water outlet)

Image

alternative text
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict, "var") – Power input, \(P/\text{W}\).

  • Q (float, dict) – Heat output of cooling, \(Q/\text{W}\)

  • e (float, dict, "var") – Electrolysis specific energy consumption, \(e/(\text{J}/\text{m}^3)\).

  • eta (float, dict) – Electrolysis efficiency, \(\eta/1\).

  • pr (float, dict, "var") – Cooling loop pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient for cooling loop pressure drop, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

Note

Other than usual components, the fuel cell has the fluid composition built into its equations for the feed hydrogen and oxygen inlets as well as the water outlet. Thus, the user must not specify the fluid composition at these connections!

Example

The example shows a simple adaptation of the fuel cell. It works with water as cooling fluid.

>>> from tespy.components import (Sink, Source, FuelCell)
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools import ComponentCharacteristics as dc_cc
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', v_unit='l / s', iterinfo=False)
>>> fc = FuelCell('fuel cell')
>>> fc.component()
'fuel cell'
>>> oxygen_source = Source('oxygen_source')
>>> hydrogen_source = Source('hydrogen_source')
>>> cw_source = Source('cw_source')
>>> cw_sink = Sink('cw_sink')
>>> water_sink = Sink('water_sink')
>>> cw_in = Connection(cw_source, 'out1', fc, 'in1')
>>> cw_out = Connection(fc, 'out1', cw_sink, 'in1')
>>> oxygen_in = Connection(oxygen_source, 'out1', fc, 'in2')
>>> hydrogen_in = Connection(hydrogen_source, 'out1', fc, 'in3')
>>> water_out = Connection(fc, 'out2', water_sink, 'in1')
>>> nw.add_conns(cw_in, cw_out, oxygen_in, hydrogen_in, water_out)

The fuel cell shall produce 200kW of electrical power and 200kW of heat with an efficiency of 0.45. The thermodynamic parameters of the input oxygen and hydrogen are given, the mass flow rates are calculated out of the given power output. The cooling fluid is pure water.

>>> fc.set_attr(eta=0.45, P=-200e03, Q=-200e03, pr=0.9)
>>> cw_in.set_attr(T=25, p=1, m=1, fluid={'H2O': 1})
>>> oxygen_in.set_attr(T=25, p=1)
>>> hydrogen_in.set_attr(T=25)
>>> nw.solve('design')
>>> P_design = fc.P.val / 1e3
>>> round(P_design, 0)
-200.0
>>> round(fc.eta.val, 2)
0.45
calc_P()[source]#

Calculate fuel cell power output.

Returns:

P (float) – Value of power output.

\[\begin{split}\begin{split} P = & +\dot{m}_{in,2} \cdot \left( h_{in,2} - h_{in,2,ref} \right)\\ & + \dot{m}_{in,3} \cdot \left( h_{in,3} - h_{in,3,ref} - e_0 \right)\\ & - \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1} \right)\\ & - \dot{m}_{out,2} \cdot \left( h_{out,2} - h_{out,2,ref} \right)\\ \end{split}\end{split}\]

Note

The temperature for the reference state is set to 25 °C, thus the produced water must be liquid as proposed in the calculation of the minimum specific energy for oxidation: tespy.components.reactors.fuel_cell.FuelCell.calc_e0(). The part of the equation regarding the cooling water is implemented with negative sign as the energy for cooling is extracted from the reactor. - Reference temperature: 298.15 K. - Reference pressure: 1 bar.

calc_e0()[source]#

Calculate the specific energy output of the fuel cell.

Returns:

float – Specific energy.

\[\begin{split}e0 = \frac{\sum_i {\Delta H_f^0}_i - \sum_j {\Delta H_f^0}_j } {M_{H_2}}\\ \forall i \in \text{reation products},\\ \forall j \in \text{reation educts},\\ \Delta H_f^0: \text{molar formation enthalpy}\end{split}\]

calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Partial derivatives for reactor energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate the residual in energy balance.

Returns:

residual (float) – Residual value of energy balance equation.

\[\begin{split}\begin{split} 0=&P + \dot{m}_\mathrm{out,2}\cdot\left(h_\mathrm{out,2}- h_\mathrm{out,2,ref}\right)\\ &+\dot{m}_\mathrm{in,1}\cdot\left( h_\mathrm{out,1} - h_\mathrm{in,1} \right)\\ & -\dot{m}_\mathrm{in,2} \cdot \left( h_\mathrm{in,2} - h_\mathrm{in,2,ref} \right)\\ & -\dot{m}_\mathrm{in,3} \cdot \left( h_\mathrm{in,3} - h_\mathrm{in,3,ref} - e_0\right)\\ \end{split}\end{split}\]
  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_balance_func_doc(label)[source]#

Calculate the residual in energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_deriv(increment_filter, k)[source]#

Partial derivatives for efficiency function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_func()[source]#

Equation for efficiency.

Returns:

residual (float) – Residual value of equation.

\[0 = P - \eta \cdot \dot{m}_{H_2,in} \cdot e_0\]

eta_func_doc(label)[source]#

Equation for efficiency.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_mandatory_constraints()[source]#
get_parameters()[source]#
heat_deriv(increment_filter, k)[source]#

Partial derivatives for heat output function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

heat_func()[source]#

Equation for heat output.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{Q}-\dot{m}_{in,1}\cdot \left(h_{out,1}-h_{in,1}\right)\]

heat_func_doc(label)[source]#

Equation for heat output.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ h\left(T=293.15, p=5 \cdot 10^5\right) & \text{key = 'h'} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ h\left(T=323.15, p=5 \cdot 10^5\right) & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static is_branch_source()[source]#
mass_flow_deriv(k)[source]#

Calculate the partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the mass flow equations.

mass_flow_func()[source]#

Equations for mass conservation.

Returns:

residual (list) – Residual values of equation.

\[\begin{split}O_2 = \frac{M_{O_2}}{M_{O_2} + 2 \cdot M_{H_2}}\\ 0=O_2\cdot\dot{m}_\mathrm{H_{2}O,out,1}- \dot{m}_\mathrm{O_2,in,2}\\ 0 = \left(1 - O_2\right) \cdot \dot{m}_\mathrm{H_{2}O,out,1} - \dot{m}_\mathrm{H_2,in,1}\end{split}\]

mass_flow_func_doc(label)[source]#

Equations for mass conservation.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
reactor_pressure_deriv(k)[source]#

Calculate the partial derivatives for combustion pressure equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the pressure equations.

reactor_pressure_func()[source]#

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equation.

\[\begin{split}0 = p_\mathrm{in,2} - p_\mathrm{out,2}\\ 0 = p_\mathrm{in,3} - p_\mathrm{out,2}\end{split}\]

reactor_pressure_func_doc(label)[source]#

Equations for reactor pressure balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

specific_energy_deriv(increment_filter, k)[source]#

Partial derivatives for specific energy function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

specific_energy_func()[source]#

Equation for specific energy output.

Returns:

residual (float) – Residual value of equation.

\[0 = P - \dot{m}_{H_2,in} \cdot e\]

specific_energy_func_doc(label)[source]#

Equation for specific energy output.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

start_branch()[source]#
start_fluid_wrapper_branch()[source]#

tespy.components.reactors.water_electrolyzer module#

Module of class WaterElectrolyzer.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/reactors/water_electrolyzer.py

SPDX-License-Identifier: MIT

class tespy.components.reactors.water_electrolyzer.WaterElectrolyzer(label, **kwargs)[source]#

Bases: Component

The water electrolyzer produces hydrogen and oxygen from water and power.

Mandatory Equations

Optional Equations

Inlets/Outlets

  • in1 (cooling inlet), in2 (feed water inlet)

  • out1 (cooling outlet), out2 (oxygen outlet), out3 (hydrogen outlet)

Image

flowsheet of the water electrolyzerflowsheet of the water electrolyzer
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict, "var") – Power input, \(P/\text{W}\).

  • Q (float, dict) – Heat output of cooling, \(Q/\text{W}\)

  • e (float, dict, "var") – Electrolysis specific energy consumption, \(e/(\text{J}/\text{m}^3)\).

  • eta (float, dict) – Electrolysis efficiency (referring to H2 higher heating value), \(\eta/1\).

  • eta_char (tespy.tools.characteristics.CharLine, dict) – Electrolysis efficiency characteristic line.

  • pr (float, dict, "var") – Cooling loop pressure ratio, \(pr/1\).

  • zeta (float, dict, "var") – Geometry independent friction coefficient for cooling loop pressure drop, \(\frac{\zeta}{D^4}/\frac{1}{\text{m}^4}\).

Note

Other than usual components, the water electrolyzer has the fluid composition built into its equations for the feed water inlet and the hydrogen and oxygen outlet. Thus, the user must not specify the fluid composition at these connections!

Example

Create a water electrolyzer and compress the hydrogen, e.g. for a hydrogen storage.

>>> from tespy.components import (Sink, Source, Compressor,
... WaterElectrolyzer)
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network(T_unit='C', p_unit='bar', v_unit='l / s', iterinfo=False)
>>> fw = Source('feed water')
>>> oxy = Sink('oxygen sink')
>>> hydro = Sink('hydrogen sink')
>>> cw_cold = Source('cooling water source')
>>> cw_hot = Sink('cooling water sink')
>>> comp = Compressor('compressor', eta_s=0.9)
>>> el = WaterElectrolyzer('electrolyzer')
>>> el.component()
'water electrolyzer'

The electrolyzer should produce 100 l/s of hydrogen at an operating pressure of 10 bars and an outlet temperature of 50 °C. The fluid composition needs to be specified for the cooling liquid only. The storage pressure is 25 bars. The electrolysis efficiency is at 80 % and the compressor isentropic efficiency at 85 %. After designing the plant the offdesign electrolysis efficiency is predicted by the characteristic line. The default characteristic line can be found here: tespy.data.

>>> fw_el = Connection(fw, 'out1', el, 'in2')
>>> el_o = Connection(el, 'out2', oxy, 'in1')
>>> el_cmp = Connection(el, 'out3', comp, 'in1')
>>> cmp_h = Connection(comp, 'out1', hydro, 'in1')
>>> cw_el = Connection(cw_cold, 'out1', el, 'in1')
>>> el_cw = Connection(el, 'out1', cw_hot, 'in1')
>>> nw.add_conns(fw_el, el_o, el_cmp, cmp_h, cw_el, el_cw)
>>> fw_el.set_attr(p=10, T=15)
>>> cw_el.set_attr(p=5, T=15, fluid={'H2O': 1})
>>> el_cw.set_attr(T=45)
>>> cmp_h.set_attr(p=25)
>>> el_cmp.set_attr(v=100, T=50)
>>> el.set_attr(eta=0.8, pr=0.99, design=['eta', 'pr'],
... offdesign=['eta_char', 'zeta'])
>>> comp.set_attr(eta_s=0.85)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(el.e0 / el.P.val * el_cmp.m.val_SI, 1)
0.8
>>> P_design = el.P.val / 1e6
>>> round(P_design, 1)
13.2
>>> nw.solve('offdesign', design_path='tmp')
>>> round(el.eta.val, 1)
0.8
>>> el_cmp.set_attr(v=None)
>>> el.set_attr(P=P_design * 0.66)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(el.eta.val, 2)
0.88
>>> shutil.rmtree('./tmp', ignore_errors=True)
bus_deriv(bus)[source]#

Calculate partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

val (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\begin{split}\dot{E} = \begin{cases} P & \text{key = 'P'}\\ - \dot{m}_{in,1} \cdot \left(h_{out,1} - h_{in,1} \right) & \text{key = 'Q'}\\ \end{cases}\end{split}\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_P()[source]#

Calculate water electrolyzer power input.

Returns:

P (float) – Value of power input.

\[\begin{split}\begin{split} P = & -\dot{m}_{in,2} \cdot \left( h_{in,2} - h_{in,2,ref} \right)\\ & + \dot{m}_{in,1} \cdot \left( h_{out,1} - h_{in,1} \right)\\ & + \dot{m}_{out,2} \cdot \left( h_{out,2} - h_{out,2,ref} \right)\\ & - \dot{m}_{out,3} \cdot \left( h_{out,3} - h_{out,3,ref} + e_0\right)\\ \end{split}\end{split}\]

Note

The temperature for the reference state is set to 25 °C, thus the feed water must be liquid as proposed in the calculation of the minimum specific energy consumption for electrolysis: tespy.components.reactors.water_electrolyzer.WaterElectrolyzer.calc_e0(). The part of the equation regarding the cooling water is implemented with negative sign as the energy for cooling is extracted from the reactor.

  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

calc_e0()[source]#

Calculate the minimum specific energy required for electrolysis.

Returns:

float – Minimum specific energy.

\[\begin{split}e0 = -\frac{\sum_i {\Delta H_f^0}_i - \sum_j {\Delta H_f^0}_j } {M_{H_2}}\\ \forall i \in \text{reation products},\\ \forall j \in \text{reation educts},\\ \Delta H_f^0: \text{molar formation enthalpy}\end{split}\]

calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Partial derivatives for reactor energy balance.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate the residual in energy balance.

Returns:

residual (float) – Residual value of energy balance equation.

\[\begin{split}\begin{split} 0=&P + \dot{m}_\mathrm{in,2}\cdot\left(h_\mathrm{in,2}- h_\mathrm{in,2,ref}\right)\\ &-\dot{m}_\mathrm{in,1}\cdot\left( h_\mathrm{out,1} - h_\mathrm{in,1} \right)\\ & -\dot{m}_\mathrm{out,2} \cdot \left( h_\mathrm{out,2} - h_\mathrm{out,2,ref} \right)\\ & +\dot{m}_\mathrm{out,3} \cdot \left( h_\mathrm{out,3} - h_\mathrm{out,3,ref} + e_0\right)\\ \end{split}\end{split}\]
  • Reference temperature: 298.15 K.

  • Reference pressure: 1 bar.

energy_balance_func_doc(label)[source]#

Calculate the residual in energy balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_char_deriv(increment_filter, k)[source]#

Partial derivatives electrolysis efficiency characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_char_func()[source]#

Equation for given efficiency characteristic of a water electrolyzer.

Returns:

residual (float) – Residual value of equation.

\[0 = P - \dot{m}_{H_2,out,3} \cdot \frac{e_0}{\eta_{design}\cdot f\left(expr \right)}\]

eta_char_func_doc(label)[source]#

Equation for given efficiency characteristic of a water electrolyzer.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_deriv(increment_filter, k)[source]#

Partial derivatives for efficiency function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_func()[source]#

Equation for electrolysis efficiency.

Returns:

residual (float) – Residual value of equation.

\[0 = P \cdot \eta - \dot{m}_{H_2,out,3} \cdot e_0\]

eta_func_doc(label)[source]#

Equation for electrolysis efficiency.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

exergy_balance(T0)[source]#

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

gas_temperature_deriv(increment_filter, k)[source]#

Partial derivatives for product gas temperature function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

gas_temperature_func()[source]#

Equation for temperature equality of product gases.

Returns:

residual (float) – Residual value of equation.

\[0 = T_\mathrm{out,2} - T_\mathrm{out,3}\]

gas_temperature_func_doc(label)[source]#

Equation for temperature equality of product gases.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_mandatory_constraints()[source]#
get_parameters()[source]#
heat_deriv(increment_filter, k)[source]#

Partial derivatives for heat output function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

heat_func()[source]#

Equation for heat output.

Returns:

residual (float) – Residual value of equation.

\[0 = \dot{Q}-\dot{m}_{in,1}\cdot \left(h_{in,1}-h_{out,1}\right)\]

heat_func_doc(label)[source]#

Equation for heat output.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

initialise_source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ h\left(T=323.15, p=5 \cdot 10^5\right) & \text{key = 'h'} \end{cases}\end{split}\]

initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^5 & \text{key = 'p'}\\ h\left(T=293.15, p=5 \cdot 10^5\right) & \text{key = 'h'} \end{cases}\end{split}\]

static inlets()[source]#
static is_branch_source()[source]#
mass_flow_deriv(k)[source]#

Calculate the partial derivatives for all mass flow balance equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the mass flow equations.

mass_flow_func()[source]#

Equations for mass conservation.

Returns:

residual (list) – Residual values of equation.

\[\begin{split}O_2 = \frac{M_{O_2}}{M_{O_2} + 2 \cdot M_{H_2}}\\ 0 =\dot{m}_\mathrm{in,1}-\dot{m}_\mathrm{out,1}\\ 0=O_2\cdot\dot{m}_\mathrm{H_{2}O,in,2}- \dot{m}_\mathrm{O_2,out,2}\\ 0 = \left(1 - O_2\right) \cdot \dot{m}_\mathrm{H_{2}O,in,2} - \dot{m}_\mathrm{H_2,out,3}\end{split}\]

mass_flow_func_doc(label)[source]#

Equations for mass conservation.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

static outlets()[source]#
preprocess(num_nw_vars)[source]#

Perform component initialization in network preprocessing.

Parameters:

nw (tespy.networks.network.Network) – Network this component is integrated in.

propagate_to_target(branch)[source]#
propagate_wrapper_to_target(branch)[source]#
reactor_pressure_deriv(k)[source]#

Calculate the partial derivatives for combustion pressure equations.

Returns:

deriv (ndarray) – Matrix with partial derivatives for the pressure equations.

reactor_pressure_func()[source]#

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equation.

\[\begin{split}0 = p_\mathrm{in,2} - p_\mathrm{out,2}\\ 0 = p_\mathrm{in,2} - p_\mathrm{out,3}\end{split}\]

reactor_pressure_func_doc(label)[source]#

Equations for reactor pressure balance.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

specific_energy_consumption_deriv(increment_filter, k)[source]#

Partial derivatives for specific energy consumption function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

specific_energy_consumption_func()[source]#

Equation for specific energy consumption.

Returns:

residual (float) – Residual value of equation.

\[0 = P - \dot{m}_{H_2,out3} \cdot e\]

specific_energy_consumption_func_doc(label)[source]#

Equation for specific energy consumption.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

start_branch()[source]#
start_fluid_wrapper_branch()[source]#

tespy.components.turbomachinery.compressor module#

Module of class Compressor.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/turbomachinery/compressor.py

SPDX-License-Identifier: MIT

class tespy.components.turbomachinery.compressor.Compressor(label, **kwargs)[source]#

Bases: Turbomachine

Class for axial or radial compressor.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the compressorflowsheet of the compressor
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict) – Power, \(P/\text{W}\)

  • eta_s (float, dict) – Isentropic efficiency, \(\eta_s/1\)

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\)

  • eta_s_char (tespy.tools.characteristics.CharLine, dict) – Characteristic curve for isentropic efficiency, provide CharLine as function func.

  • char_map (tespy.tools.characteristics.CharMap, dict) – Characteristic map for pressure rise and isentropic efficiency vs. nondimensional mass flow, see tespy.tools.characteristics.CharMap for further information. Provide a CompressorMap as function func.

  • igva (float, dict, "var") – Inlet guide vane angle, \(igva/^\circ\).

Example

Create an air compressor model and calculate the power required for compression of 50 l/s of ambient air to 5 bars. Using a generic compressor map how does the efficiency change in different operation mode (e.g. 90 % of nominal volumetric flow)?

>>> from tespy.components import Sink, Source, Compressor
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', h_unit='kJ / kg', v_unit='l / s',
... iterinfo=False)
>>> si = Sink('sink')
>>> so = Source('source')
>>> comp = Compressor('compressor')
>>> comp.component()
'compressor'
>>> inc = Connection(so, 'out1', comp, 'in1')
>>> outg = Connection(comp, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)

Specify the compressor parameters: nominal efficiency and pressure ratio. For offdesign mode the characteristic map is selected instead of the isentropic efficiency. For offdesign, the inlet guide vane angle should be variable in order to maintain the same pressure ratio at a different volumetric flow.

>>> comp.set_attr(pr=5, eta_s=0.8, design=['eta_s'],
... offdesign=['char_map_pr', 'char_map_eta_s'])
>>> inc.set_attr(fluid={'air': 1}, p=1, T=20, v=50)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(comp.P.val, 0)
12772.0
>>> inc.set_attr(v=45)
>>> comp.set_attr(igva='var')
>>> nw.solve('offdesign', design_path='tmp')
>>> round(comp.eta_s.val, 2)
0.77
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

char_map_eta_s_deriv(increment_filter, k)[source]#

Partial derivatives for compressor map characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

char_map_eta_s_func()[source]#

Calculate isentropic efficiency from characteristic map.

Returns:

residual (float) – Residual value of equation.

Note

  • X: speedline index (rotational speed is constant)

  • Y: nondimensional mass flow

  • igva: variable inlet guide vane angle for value manipulation according to [23].

\[\begin{split}X = \sqrt{\frac{T_\mathrm{in,design}}{T_\mathrm{in}}}\\ Y = \frac{\dot{m}_\mathrm{in} \cdot p_\mathrm{in,design}} {\dot{m}_\mathrm{in,design} \cdot p_\mathrm{in} \cdot X}\\ \vec{Y} = f\left(X,Y\right)\cdot\left(1-\frac{igva}{100}\right)\\ \vec{Z}=f\left(X,Y\right)\cdot\left(1-\frac{igva^2}{10000}\right)\\ 0 = \frac{\eta_\mathrm{s}}{\eta_\mathrm{s,design}} - f\left(Y,\vec{Y},\vec{Z}\right)\end{split}\]
char_map_eta_s_func_doc(label)[source]#

Get LaTeX equation for isentropic efficiency from characteristic map.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

char_map_pr_deriv(increment_filter, k)[source]#

Partial derivatives for compressor map characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

char_map_pr_func()[source]#

Calculate pressure ratio from characteristic map.

Returns:

residual (float) – Residual value of equations.

Note

  • X: speedline index (rotational speed is constant)

  • Y: nondimensional mass flow

  • igva: variable inlet guide vane angle for value manipulation according to [23].

\[\begin{split}X = \sqrt{\frac{T_\mathrm{in,design}}{T_\mathrm{in}}}\\ Y = \frac{\dot{m}_\mathrm{in} \cdot p_\mathrm{in,design}} {\dot{m}_\mathrm{in,design} \cdot p_\mathrm{in} \cdot X}\\ \vec{Y} = f\left(X,Y\right)\cdot\left(1-\frac{igva}{100}\right)\\ \vec{Z} = f\left(X,Y\right)\cdot\left(1-\frac{igva}{100}\right)\\ 0 = \frac{p_{out} \cdot p_{in,design}} {p_\mathrm{in} \cdot p_\mathrm{out,design}}- f\left(Y,\vec{Y},\vec{Z}\right)\end{split}\]
char_map_pr_func_doc(label)[source]#

Get LaTeX equation for pressure ratio from characteristic map.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

check_parameter_bounds()[source]#

Check parameter value limits.

static component()[source]#
convergence_check()[source]#

Perform a convergence check.

Note

Manipulate enthalpies/pressure at inlet and outlet if not specified by user to match physically feasible constraints.

eta_s_char_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_char_func()[source]#

Equation for given isentropic efficiency characteristic.

Returns:

residual (float) – Residual value of equation.

\[0 = \left(h_{out}-h_{in}\right) \cdot \eta_{s,design} \cdot f\left( expr \right) -\left( h_{out,s} - h_{in} \right)\]

eta_s_char_func_doc(label)[source]#

Equation for given isentropic efficiency characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_s_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_func()[source]#

Equation for given isentropic efficiency of a compressor.

Returns:

residual (float) – Residual value of equation.

\[0 = -\left( h_{out} - h_{in} \right) \cdot \eta_{s} + \left( h_{out,s} - h_{in} \right)\]

eta_s_func_doc(label)[source]#

Equation for given isentropic efficiency of a compressor.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

exergy_balance(T0)[source]#

Calculate exergy balance of a compressor.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \dot{E}_\mathrm{out}^\mathrm{PH} - \dot{E}_\mathrm{in}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{out}^\mathrm{T} + \dot{E}_\mathrm{out}^\mathrm{M} - \dot{E}_\mathrm{in}^\mathrm{M} & T_\mathrm{out} > T_0 \leq T_\mathrm{in}\\ \dot{E}_\mathrm{out}^\mathrm{M} - \dot{E}_\mathrm{in}^\mathrm{M} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} P & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ P + \dot{E}_\mathrm{in}^\mathrm{T} & T_\mathrm{out} > T_0 \leq T_\mathrm{in}\\ P + \dot{E}_\mathrm{in}^\mathrm{T} -\dot{E}_\mathrm{out}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\dot{E}_\mathrm{bus} = P\end{aligned}\end{align} \]
get_parameters()[source]#
static initialise_Source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^6 & \text{key = 'p'}\\ 6 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^5 & \text{key = 'p'}\\ 4 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

tespy.components.turbomachinery.pump module#

Module of class Pump.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/turbomachinery/pump.py

SPDX-License-Identifier: MIT

class tespy.components.turbomachinery.pump.Pump(label, **kwargs)[source]#

Bases: Turbomachine

Class for axial or radial pumps.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the pumpflowsheet of the pump
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict) – Power, \(P/\text{W}\)

  • eta_s (float, dict) – Isentropic efficiency, \(\eta_s/1\)

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\)

  • eta_s_char (tespy.tools.characteristics.CharLine, dict) – Characteristic curve for isentropic efficiency, provide CharLine as function func.

  • flow_char (tespy.tools.characteristics.CharLine, dict) – Characteristic curve for pressure rise as function of volumetric flow \(x/\frac{\text{m}^3}{\text{s}} \, y/\text{Pa}\).

Example

A pump with a known pump curve (difference pressure as function of volumetric flow) pumps 1,5 l/s of water in design conditions. E.g. for a given isentropic efficiency it is possible to calculate power consumption and pressure at the pump.

>>> from tespy.components import Sink, Source, Pump
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools.characteristics import CharLine
>>> import numpy as np
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', h_unit='kJ / kg', v_unit='l / s',
... iterinfo=False)
>>> si = Sink('sink')
>>> so = Source('source')
>>> pu = Pump('pump')
>>> pu.component()
'pump'
>>> inc = Connection(so, 'out1', pu, 'in1')
>>> outg = Connection(pu, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)

After that we calculate offdesign performance using the pump curve and a characteristic function for the pump efficiency. We can calulate the offdesign efficiency and the volumetric flow, if the difference pressure changed. The default characteristc lines are to be found in the tespy.data module. Of course you are able to specify your own characteristcs, like done for the flow_char. More information on how to specify characteristic functions are given in the corresponding part of the online documentation.

>>> v = np.array([0, 0.4, 0.8, 1.2, 1.6, 2]) / 1000
>>> dp = np.array([15, 14, 12, 9, 5, 0]) * 1e5
>>> char = CharLine(x=v, y=dp)
>>> pu.set_attr(eta_s=0.8, flow_char={'char_func': char, 'is_set': True},
... design=['eta_s'], offdesign=['eta_s_char'])
>>> inc.set_attr(fluid={'water': 1}, p=1, T=20, v=1.5, design=['v'])
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(pu.pr.val, 0)
7.0
>>> round(outg.p.val - inc.p.val, 0)
6.0
>>> round(pu.P.val, 0)
1125.0
>>> outg.set_attr(p=12)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(pu.eta_s.val, 2)
0.71
>>> round(inc.v.val, 1)
0.9
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
convergence_check()[source]#

Perform a convergence check.

Note

Manipulate enthalpies/pressure at inlet and outlet if not specified by user to match physically feasible constraints.

eta_s_char_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_char_func()[source]#

Equation for given isentropic efficiency characteristic.

Returns:

residual (float) – Residual value of equation.

\[0 = \left(h_{out}-h_{in}\right) \cdot \eta_{s,design} \cdot f\left( expr \right) -\left( h_{out,s} - h_{in} \right)\]

eta_s_char_func_doc(label)[source]#

Equation for given isentropic efficiency characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_s_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_func()[source]#

Equation for given isentropic efficiency.

Returns:

residual (float) – Residual value of equation.

\[0 = -\left( h_{out} - h_{in} \right) \cdot \eta_{s} + \left( h_{out,s} - h_{in} \right)\]

eta_s_func_doc(label)[source]#

Equation for given isentropic efficiency.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

exergy_balance(T0)[source]#

Calculate exergy balance of a pump.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[ \begin{align}\begin{aligned}\begin{split}\dot{E}_\mathrm{P} = \begin{cases} \dot{E}_\mathrm{out}^\mathrm{PH} - \dot{E}_\mathrm{in}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{out}^\mathrm{T} + \dot{E}_\mathrm{out}^\mathrm{M} - \dot{E}_\mathrm{in}^\mathrm{M} & T_\mathrm{out} > T_0 \leq T_\mathrm{in}\\ \dot{E}_\mathrm{out}^\mathrm{M} - \dot{E}_\mathrm{in}^\mathrm{M} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} P & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ P + \dot{E}_\mathrm{in}^\mathrm{T} & T_\mathrm{out} > T_0 \leq T_\mathrm{in}\\ P + \dot{E}_\mathrm{in}^\mathrm{T} -\dot{E}_\mathrm{out}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\dot{E}_\mathrm{bus} = P\end{aligned}\end{align} \]
flow_char_deriv(increment_filter, k)[source]#

Partial derivatives for flow characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

flow_char_func()[source]#

Equation for given flow characteristic of a pump.

Returns:

residual (float) – Residual value of equation.

\[0 = p_{out} - p_{in} - f\left( expr \right)\]

flow_char_func_doc(label)[source]#

Equation for given flow characteristic of a pump.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

get_parameters()[source]#
static initialise_Source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^6 & \text{key = 'p'}\\ 3 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 10^5 & \text{key = 'p'}\\ 2.9 \cdot 10^5 & \text{key = 'h'} \end{cases}\end{split}\]

tespy.components.turbomachinery.turbine module#

Module of class Turbine.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/turbomachinery/turbine.py

SPDX-License-Identifier: MIT

class tespy.components.turbomachinery.turbine.Turbine(label, **kwargs)[source]#

Bases: Turbomachine

Class for gas or steam turbines.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Image

flowsheet of the turbineflowsheet of the turbine
Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict) – Power, \(P/\text{W}\)

  • eta_s (float, dict) – Isentropic efficiency, \(\eta_s/1\)

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\)

  • eta_s_char (tespy.tools.characteristics.CharLine, dict) – Characteristic curve for isentropic efficiency, provide CharLine as function func.

  • cone (dict) – Apply Stodola’s cone law (works in offdesign only).

Example

A steam turbine expands 10 kg/s of superheated steam at 550 °C and 110 bar to 0,5 bar at the outlet. For example, it is possible to calulate the power output and vapour content at the outlet for a given isentropic efficiency.

>>> from tespy.components import Sink, Source, Turbine
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> from tespy.tools import ComponentCharacteristics as dc_cc
>>> import shutil
>>> nw = Network(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> si = Sink('sink')
>>> so = Source('source')
>>> t = Turbine('turbine')
>>> t.component()
'turbine'
>>> inc = Connection(so, 'out1', t, 'in1')
>>> outg = Connection(t, 'out1', si, 'in1')
>>> nw.add_conns(inc, outg)

In design conditions the isentropic efficiency is specified. For offdesign a characteristic function will be applied, together with Stodola’s cone law coupling the turbine mass flow to inlet pressure.

>>> t.set_attr(eta_s=0.9, design=['eta_s'],
... offdesign=['eta_s_char', 'cone'])
>>> inc.set_attr(fluid={'water': 1}, m=10, T=550, p=110, design=['p'])
>>> outg.set_attr(p=0.5)
>>> nw.solve('design')
>>> nw.save('tmp')
>>> round(t.P.val, 0)
-10452574.0
>>> round(outg.x.val, 3)
0.914
>>> inc.set_attr(m=8)
>>> nw.solve('offdesign', design_path='tmp')
>>> round(t.eta_s.val, 3)
0.898
>>> round(inc.p.val, 1)
88.6
>>> shutil.rmtree('./tmp', ignore_errors=True)
calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
cone_deriv(increment_filter, k)[source]#

Partial derivatives for stodolas cone law.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

cone_func()[source]#

Equation for stodolas cone law.

Returns:

residual (float) – Residual value of equation.

\[0 = \frac{\dot{m}_{in,ref} \cdot p_{in}}{p_{in,ref}} \cdot \sqrt{\frac{p_{in,ref} \cdot v_{in}}{p_{in} \cdot v_{in,ref}}} \cdot \sqrt{\frac{1 - \left(\frac{p_{out}}{p_{in}} \right)^{2}} {1 - \left(\frac{p_{out,ref}}{p_{in,ref}} \right)^{2}}} - \dot{m}_{in}\]

cone_func_doc(label)[source]#

Equation for stodolas cone law.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

convergence_check()[source]#

Perform a convergence check.

Note

Manipulate enthalpies/pressure at inlet and outlet if not specified by user to match physically feasible constraints.

eta_s_char_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency characteristic.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_char_func()[source]#

Equation for given isentropic efficiency characteristic.

Returns:

residual (float) – Residual value of equation.

\[0 = - \left( h_\mathrm{out} - h_\mathrm{in} \right) + \eta_\mathrm{s,design} \cdot f\left( expr \right) \cdot \left(h_\mathrm{out,s}-h_\mathrm{in}\right)\]

eta_s_char_func_doc(label)[source]#

Equation for given isentropic efficiency characteristic.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

eta_s_deriv(increment_filter, k)[source]#

Partial derivatives for isentropic efficiency function.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

eta_s_func()[source]#

Equation for given isentropic efficiency of a turbine.

Returns:

residual (float) – Residual value of equation.

\[0 = -\left( h_{out} - h_{in} \right) + \left( h_{out,s} - h_{in} \right) \cdot \eta_{s,e}\]

eta_s_func_doc(label)[source]#

Equation for given isentropic efficiency of a turbine.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

exergy_balance(T0)[source]#

Calculate exergy balance of a turbine.

Parameters:

T0 (float) – Ambient temperature T0 / K.

Note

\[ \begin{align}\begin{aligned}\begin{split} \dot{E}_\mathrm{P} = \begin{cases} -P & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ -P + \dot{E}_\mathrm{out}^\mathrm{T} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ -P +\dot{E}_\mathrm{out}^\mathrm{T}- \dot{E}_\mathrm{in}^\mathrm{T} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\begin{split}\dot{E}_\mathrm{F} = \begin{cases} \dot{E}_\mathrm{in}^\mathrm{PH} - \dot{E}_\mathrm{out}^\mathrm{PH} & T_\mathrm{in}, T_\mathrm{out} \geq T_0\\ \dot{E}_\mathrm{in}^\mathrm{T} + \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_\mathrm{in} > T_0 \geq T_\mathrm{out}\\ \dot{E}_\mathrm{in}^\mathrm{M} - \dot{E}_\mathrm{out}^\mathrm{M} & T_0 \geq T_\mathrm{in}, T_\mathrm{out}\\ \end{cases}\end{split}\\\dot{E}_\mathrm{bus} = -P\end{aligned}\end{align} \]
get_parameters()[source]#
static initialise_Source(c, key)[source]#

Return a starting value for pressure and enthalpy at outlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 5 \cdot 10^4 & \text{key = 'p'}\\ 1.5 \cdot 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

static initialise_target(c, key)[source]#

Return a starting value for pressure and enthalpy at inlet.

Parameters:
  • c (tespy.connections.connection.Connection) – Connection to perform initialisation on.

  • key (str) – Fluid property to retrieve.

Returns:

val (float) – Starting value for pressure/enthalpy in SI units.

\[\begin{split}val = \begin{cases} 2.5 \cdot 10^6 & \text{key = 'p'}\\ 2 \cdot 10^6 & \text{key = 'h'} \end{cases}\end{split}\]

tespy.components.turbomachinery.base module#

Module of class Turbomachine.

This file is part of project TESPy (github.com/oemof/tespy). It’s copyrighted by the contributors recorded in the version control history of the file, available from its original location tespy/components/turbomachinery/base.py

SPDX-License-Identifier: MIT

class tespy.components.turbomachinery.base.Turbomachine(label, **kwargs)[source]#

Bases: Component

Parent class for compressor, pump and turbine.

Mandatory Equations

  • tespy.components.component.Component.fluid_func()

  • tespy.components.component.Component.mass_flow_func()

Optional Equations

Inlets/Outlets

  • in1

  • out1

Parameters:
  • label (str) – The label of the component.

  • design (list) – List containing design parameters (stated as String).

  • offdesign (list) – List containing offdesign parameters (stated as String).

  • design_path (str) – Path to the components design case.

  • local_offdesign (boolean) – Treat this component in offdesign mode in a design calculation.

  • local_design (boolean) – Treat this component in design mode in an offdesign calculation.

  • char_warnings (boolean) – Ignore warnings on default characteristics usage for this component.

  • printout (boolean) – Include this component in the network’s results printout.

  • P (float, dict) – Power, \(P/\text{W}\)

  • pr (float, dict, "var") – Outlet to inlet pressure ratio, \(pr/1\)

Example

For an example please refer to:

bus_deriv(bus)[source]#

Calculate partial derivatives of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

deriv (ndarray) – Matrix of partial derivatives.

bus_func(bus)[source]#

Calculate the value of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

residual (float) – Value of energy transfer \(\dot{E}\). This value is passed to tespy.components.component.Component.calc_bus_value() for value manipulation according to the specified characteristic line of the bus.

\[\dot{E} = \dot{m}_{in} \cdot \left(h_{out} - h_{in} \right)\]

bus_func_doc(bus)[source]#

Return LaTeX string of the bus function.

Parameters:

bus (tespy.connections.bus.Bus) – TESPy bus object.

Returns:

latex (str) – LaTeX string of bus function.

calc_parameters()[source]#

Postprocessing parameter calculation.

static component()[source]#
energy_balance_deriv(increment_filter, k)[source]#

Calculate partial derivatives of energy balance of a turbomachine.

Parameters:
  • increment_filter (ndarray) – Matrix for filtering non-changing variables.

  • k (int) – Position of derivatives in Jacobian matrix (k-th equation).

energy_balance_func()[source]#

Calculate energy balance of a turbomachine.

Returns:

residual (float) – Residual value of turbomachine energy balance

\[0=\dot{m}_{in}\cdot\left(h_{out}-h_{in}\right)-P\]

energy_balance_func_doc(label)[source]#

Calculate energy balance of a turbomachine.

Parameters:

label (str) – Label for equation.

Returns:

latex (str) – LaTeX code of equations applied.

entropy_balance()[source]#

Calculate entropy balance of turbomachine.

Note

The entropy balance makes the follwing parameter available:

\[\begin{split}\text{S\_irr}=\dot{m} \cdot \left(s_\mathrm{out}-s_\mathrm{in} \right)\\\end{split}\]
get_parameters()[source]#
get_plotting_data()[source]#

Generate a dictionary containing FluProDia plotting information.

Returns:

data (dict) – A nested dictionary containing the keywords required by the calc_individual_isoline method of the FluidPropertyDiagram class. First level keys are the connection index (‘in1’ -> ‘out1’, therefore 1 etc.).

static inlets()[source]#
static outlets()[source]#