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]
dp_dependents(dp=None, inconn=None, outconn=None)[source]
dp_func(dp=None, inconn=None, outconn=None)[source]

Calculate residual value of pressure difference function.

Parameters:
  • dp (str) – Component parameter to evaluate the dp_func on, e.g. dp1.

  • inconn (int) – Connection index of inlet.

  • outconn (int) – Connection index of outlet.

Returns:

residual (float) – Residual value of function.

\[0 = p_{in} - p_{out} - dp\]

dp_structure_matrix(k, dp=None, inconn=0, outconn=0)[source]
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_bypass_constraints()[source]
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_mandatory_constraints()[source]
get_parameters()[source]
get_plotting_data()[source]
get_variables()[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 outlets()[source]
static powerinlets()[source]
static poweroutlets()[source]
pr_dependents(pr=None, inconn=0, outconn=0)[source]
pr_deriv(increment_filter, k, pr=None, 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=None, 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_structure_matrix(k, pr=None, inconn=0, outconn=0)[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.

variable_equality_structure_matrix(k, **kwargs)[source]
zeta_dependents(zeta=None, inconn=0, outconn=0)[source]
zeta_func(zeta=None, 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}\]
tespy.components.component.component_registry(type)[source]

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
>>> class MySubsystem(Subsystem):
...     def create_network(self):
...         pass
>>> mysub = MySubsystem('mySubsystem')
>>> type(mysub)
<class 'tespy.components.subsystem.MySubsystem'>
>>> mysub.label
'mySubsystem'
>>> type(mysub.inlet)
<class 'tespy.components.basics.subsystem_interface.SubsystemInterface'>
>>> type(mysub.outlet)
<class 'tespy.components.basics.subsystem_interface.SubsystemInterface'>

If you want to connect to the subsystem from outside of it in a Network, then you have to pass the respective number of inlet and outlet connections. The number is to your choice, but for the Subsystem to be functional, all of the available interfaces must be wired properly internally in the create_network method. For example, consider a subsystem which is just passing its inlet to the outlet:

>>> from tespy.components import Source, Sink
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> class MySubsystem(Subsystem):
...     def __init__(self, label):
...         self.num_in = 1
...         self.num_out = 1
...         super().__init__(label)
...
...     def create_network(self):
...         c1 = Connection(self.inlet, "out1", self.outlet, "in1", label="1")
...         self.add_conns(c1)
>>> mysub = MySubsystem('mySubsystem')
>>> nw = Network()
>>> so = Source("source")
>>> si = Sink("sink")
>>> c1 = Connection(so, "out1", mysub, "in1", label="1")
>>> c2 = Connection(mysub, "out1", si, "in1", label="2")
>>> nw.add_conns(c1, c2)
>>> nw.add_subsystems(mysub)

We can run the check_topology method to check if everything is properly connected and a valid topology was created, without needing to parametrize the system (for the sake of simplicity in this example).

>>> nw.check_topology()

You can retrieve components and connections from inside the subsystem with their label, which is used inside the create_network method of the subsystem.

>>> type(mysub.get_conn("1"))
<class 'tespy.connections.connection.Connection'>
>>> type(mysub.get_comp("inlet"))
<class 'tespy.components.basics.subsystem_interface.SubsystemInterface'>

Their actual label is prefixed with the subsystem’s label, and therefore to get it from the network level, you must use that label:

>>> mysub.get_conn("1").label
'mySubsystem_1'
>>> type(nw.get_conn('mySubsystem_1'))
<class 'tespy.connections.connection.Connection'>

The same is true for components:

>>> mysub.get_comp("inlet").label
'mySubsystem_inlet'
>>> type(nw.get_comp("mySubsystem_inlet"))
<class 'tespy.components.basics.subsystem_interface.SubsystemInterface'>
add_conns(*args)[source]
create_network()[source]

Create the subsystem’s network.

get_comp(label)[source]
get_conn(label)[source]

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')
>>> 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.

get_mandatory_constraints()[source]
static get_parameters()[source]
static inlets()[source]
static outlets()[source]
propagate_wrapper_to_target(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.label
'a labeled sink'
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_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.label
'a labeled 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 outlets()[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

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

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

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

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

Inlets/Outlets

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

Image

flowsheet of the subsystem interface flowsheet 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)
>>> 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)
>>> outg2.set_attr(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
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, carbon monoxide, nDodecane

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamber flowsheet 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
>>> 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')
>>> 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)
>>> 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})
>>> comb_fg.set_attr(T=1200)
>>> 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}\]

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: [18]

  • Source for all other fluids: [19]

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_structure_matrix(k)[source]

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equations.

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

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_dependents()[source]
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.

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 [20]. 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]
lambda_dependents()[source]
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} \]

mass_flow_dependents()[source]
mass_flow_deriv(increment_filter, k, dependents=None)[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}\]

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

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

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_dependents()[source]
stoichiometry_deriv(increment_filter, k, dependents=None)[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.

ti_dependents()[source]
ti_deriv(increment_filter, k, dependents=None)[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\]

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, carbon monoxide, nDodecane

Inlets/Outlets

  • in1, in2

  • out1

Image

flowsheet of the combustion chamber flowsheet 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
>>> 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')
>>> 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)
>>> 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(
...     p=1.3, T=25, fluid={'CO2': 0.03, 'H2': 0.01, 'CH4': 0.96}
... )
>>> comb_fg.set_attr(T=1200)
>>> 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 Qloss has a negative value as it is extracted from the system.

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

Postprocessing parameter calculation.

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.

exergy_balance(T0)[source]

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

get_mandatory_constraints()[source]
get_parameters()[source]

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, carbon monoxide, nDodecane

Inlets/Outlets

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

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

Power outlets

  • power

Image

flowsheet of the combustion engine flowsheet 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 os
>>> 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')
>>> 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.json')
>>> 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.json', design_path='tmp.json')
>>> 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.json', design_path='tmp.json')
>>> round(chp.ti.val, 0)
20550000.0
>>> round(chp.P.val / chp.P.design, 3)
0.75
>>> os.remove('tmp.json')
Q1_char_dependents()[source]
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_dependents()[source]
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\]

Q2_char_dependents()[source]
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_dependents()[source]
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\]

Qloss_char_dependents()[source]
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}\]

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}\]

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.

energy_balance_dependents()[source]
energy_balance_deriv(increment_filter, k, dependents=None)[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_connector_balance_func()[source]
energy_connector_dependents()[source]
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 [21]. 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 [20]. 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]
get_variables()[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]
static poweroutlets()[source]
propagate_wrapper_to_target(branch)[source]
tiP_char_dependents()[source]
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]\]

variable_equality_structure_matrix(k, **kwargs)[source]

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 exchanger flowsheet 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\).

  • dp1 (float, dict, "var") – Inlet to outlet pressure delta at hot side, unit is the network’s pressure unit!.

  • dp2 (float, dict, "var") – Inlet to outlet pressure delta at cold side, unit is the network’s pressure unit!.

  • 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}\).

  • ttd_min (float, dict) – Minumum terminal temperature difference \(ttd_\mathrm{min}/\text{K}\).

  • eff_cold (float, dict) – Cold side heat exchanger effectiveness \(eff_\text{cold}/\text{1}\).

  • eff_hot (float, dict) – Hot side heat exchanger effectiveness \(eff_\text{hot}/\text{1}\).

  • eff_max (float, dict) – Max value of hot and cold side heat exchanger effectiveness values \(eff_\text{max}/\text{1}\).

  • 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
>>> import os
>>> 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')
>>> 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'])
>>> he_cw.set_attr(h0=1e2)
>>> 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.json')
>>> 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.json')
>>> 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.json')
>>> round(he_cw.T.val, 1)
33.9
>>> round(he_ex.T.val, 1)
18.8
>>> os.remove("tmp.json")
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)\]

calc_dh_max_cold()[source]

Calculate the theoretical maximum enthalpy increase on the cold side

Returns:

float – Maxmium cold side enthalpy increase.

\[h\left(p_{out,2}, T_{in,1}\right) - h_{in,2}\]

calc_dh_max_hot()[source]

Calculate the theoretical maximum enthalpy decrease on the hot side

Returns:

float – Maxmium hot side enthalpy decrease.

\[h\left(p_{out,1}, T_{in,2}\right) - h_{in,1}\]

calc_parameters()[source]

Postprocessing parameter calculation.

calculate_td_log()[source]
eff_cold_dependents()[source]
eff_cold_func()[source]

Equation for cold side heat exchanger effectiveness.

Returns:

residual (float) – Residual value of equation.

\[0 = \text{eff}_\text{cold} \cdot \left(h\left(p_{out,2}, T_{in,1} \right) - h_{in,2}\right) - \left( h_{out,2} - h_{in,2} \right)\]

eff_hot_dependents()[source]
eff_hot_func()[source]

Equation for hot side heat exchanger effectiveness.

Returns:

residual (float) – Residual value of equation.

\[0 = \text{eff}_\text{hot} \cdot \left(h\left(p_{out,1}, T_{in,2}\right) - h_{in,1}\right) - \left( h_{out,1} - h_{in,1}\right)\]

eff_max_dependents()[source]
eff_max_func()[source]

Equation for maximum heat exchanger effectiveness.

Note

This functions works on what is larger: hot side or cold side effectiveness. It may cause numerical issues, if applied, when one of both sides’ effectiveness is already predetermined, e.g. by temperature specifications.

Returns:

residual (float) – Residual value of equation.

\[0 = \text{eff}_\text{max} - \text{max} \left(\text{eff}_\text{hot},\text{eff}_\text{cold}\right)\]

energy_balance_dependents()[source]
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_hot_dependents()[source]
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}\]

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_bypass_constraints()[source]
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_dependents()[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_{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_dependents()[source]
kA_deriv(increment_filter, k, dependents=None)[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}}}}\]

static outlets()[source]
ttd_l_dependents()[source]
ttd_l_func()[source]

Equation for lower terminal temperature difference.

Returns:

residual (float) – Residual value of equation.

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

ttd_min_dependents()[source]
ttd_min_func()[source]

Equation for minimum terminal temperature difference.

Returns:

residual (float) – Residual value of equation.

\[ttd_{l} = T_{out,1} - T_{in,2} ttd_{u} = T_{in,1} - T_{out,2} 0 = \text{min}\left(ttd_{u}, ttd_{l}\right)\]

ttd_u_dependents()[source]
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}\]

tespy.components.heat_exchangers.movingboundary module

Module of class MovingBoundaryCondenser.

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/movingboundary.py

SPDX-License-Identifier: MIT

class tespy.components.heat_exchangers.movingboundary.MovingBoundaryHeatExchanger(label, **kwargs)[source]

Bases: HeatExchanger

Class for counter current heat exchanger with UA sections.

The heat exchanger is internally discretized into multiple sections, which are defined by phase changes. The component assumes, that no pressure losses occur. In principle the implementations follows [22].

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 exchanger flowsheet 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\).

  • dp1 (float, dict, "var") – Inlet to outlet pressure delta at hot side, unit is the network’s pressure unit!.

  • dp2 (float, dict, "var") – Inlet to outlet pressure delta at cold side, unit is the network’s pressure unit!.

  • 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}\).

  • ttd_min (float, dict) – Minumum terminal temperature difference \(ttd_\mathrm{min}/\text{K}\).

  • eff_cold (float, dict) – Cold side heat exchanger effectiveness \(eff_\text{cold}/\text{1}\).

  • eff_hot (float, dict) – Hot side heat exchanger effectiveness \(eff_\text{hot}/\text{1}\).

  • eff_max (float, dict) – Max value of hot and cold side heat exchanger effectiveness values \(eff_\text{max}/\text{1}\).

  • 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.

  • UA (float, dict) – Sum of UA in all sections of the heat exchanger.

  • td_pinch (float, dict) – Value of the lowest delta T between hot side and cold side at the different sections.

Note

The equations only apply to counter-current heat exchangers.

Example

Water vapor should be cooled down, condensed and then further subcooled. For this air is heated up from 15 °C to 25 °C.

>>> from tespy.components import Source, Sink, MovingBoundaryHeatExchanger
>>> from tespy.connections import Connection
>>> from tespy.networks import Network
>>> import numpy as np
>>> nw = Network(T_unit="C", p_unit="bar")
>>> nw.set_attr(iterinfo=False)
>>> so1 = Source("vapor source")
>>> so2 = Source("air source")
>>> cd = MovingBoundaryHeatExchanger("condenser")
>>> si1 = Sink("water sink")
>>> si2 = Sink("air sink")
>>> c1 = Connection(so1, "out1", cd, "in1", label="1")
>>> c2 = Connection(cd, "out1", si1, "in1", label="2")
>>> c11 = Connection(so2, "out1", cd, "in2", label="11")
>>> c12 = Connection(cd, "out2", si2, "in1", label="12")
>>> nw.add_conns(c1, c2, c11, c12)

To generate good guess values, first we run the simulation with fixed pressure on the water side. The water enters at superheated vapor state with 15 °C superheating and leaves it with 10 °C subcooling.

>>> c1.set_attr(fluid={"Water": 1}, p=1, Td_bp=15, m=1)
>>> c2.set_attr(Td_bp=-15)
>>> c11.set_attr(fluid={"Air": 1}, p=1, T=15)
>>> c12.set_attr(T=25)
>>> cd.set_attr(pr1=1, pr2=1)
>>> nw.solve("design")

Now we can remove the pressure specifications on the air side and impose the minimum pinch instead, which will determine the actual water condensation pressure.

>>> c1.set_attr(p=None)
>>> cd.set_attr(td_pinch=5)
>>> nw.solve("design")
>>> round(c1.p.val, 3)
0.056

We can also see the temperature differences in all sections of the heat exchanger. Since the water vapor is cooled, condensed and then subcooled, while the air does not change phase, three sections will form:

>>> Q_sections, T_steps_hot, T_steps_cold, Q_per_section, td_log_per_section = cd.calc_sections()
>>> T_steps_hot, T_steps_cold = cd._get_T_at_steps(Q_sections)
>>> delta_T_between_sections = T_steps_hot - T_steps_cold
>>> [round(float(dT), 2) for dT in delta_T_between_sections]
[5.0, 19.75, 10.11, 25.0]

We can see that the lowest delta T is the first one. This is the delta T between the hot side outlet and the cold side inlet, which can also be seen if we have a look at the network’s results.

>>> ();nw.print_results();() 
(...)

If we change the subcooling degree at the water outlet, the condensation pressure and pinch will move.

>>> c2.set_attr(Td_bp=-5)
>>> nw.solve("design")
>>> round(c1.p.val, 3)
0.042
>>> Q_sections, T_steps_hot, T_steps_cold, Q_per_section, td_log_per_section = cd.calc_sections()
>>> T_steps_hot, T_steps_cold = cd._get_T_at_steps(Q_sections)
>>> delta_T_between_sections = T_steps_hot - T_steps_cold
>>> [round(float(dT), 2) for dT in delta_T_between_sections]
[9.88, 14.8, 5.0, 19.88]

Finally, in contrast to the baseclass HeatExchanger kA value, the UA value takes into account the heat transfer per section and calculates the heat transfer coefficient as the sum of all sections, while the kA value only takes into account the inlet and outlet temperatures and the total heat transfer.

>>> round(cd.kA.val)
173307
>>> round(cd.UA.val)
273449
UA_dependents()[source]
UA_func(**kwargs)[source]

Calculate heat transfer from heat transfer coefficients for desuperheating and condensation as well as total heat exchange area.

Returns:

residual (float) – Residual value of equation.

\[0 = UA - \sum UA_\text{i}\]

calc_UA(sections)[source]

Calculate the sum of UA for all sections in the heat exchanger

Returns:

float – Sum of UA values of all heat exchanger sections.

calc_parameters()[source]

Postprocessing parameter calculation.

calc_sections()[source]

Calculate the sections of the heat exchanger.

Returns:

tuple – Cumulated heat transfer over sections, temperature at steps hot side, temperature at steps cold side, heat transfer per section

calc_td_pinch(sections)[source]

Calculate the pinch point temperature difference

Returns:

float – Value of the pinch point temperature difference

get_parameters()[source]
td_pinch_dependents()[source]
td_pinch_func()[source]

Equation for pinch point temperature difference of a condenser.

Returns:

residual (float) – Residual value of equation.

\[0 = td_\text{pinch} - min(td_\text{sections})\]

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 condenser flowsheet 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\).

  • dp1 (float, dict, "var") – Inlet to outlet pressure delta at hot side, unit is the network’s pressure unit!.

  • dp2 (float, dict, "var") – Inlet to outlet pressure delta at cold side, unit is the network’s pressure unit!.

  • 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}\).

  • ttd_min (float, dict) – Minumum terminal temperature difference \(ttd_\mathrm{min}/\text{K}\).

  • eff_cold (float, dict) – Cold side heat exchanger effectiveness \(eff_\text{cold}/\text{1}\).

  • eff_hot (float, dict) – Hot side heat exchanger effectiveness \(eff_\text{hot}/\text{1}\).

  • eff_max (float, dict) – Max value of hot and cold side heat exchanger effectiveness values \(eff_\text{max}/\text{1}\).

  • 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 os
>>> 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')
>>> 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.json')
>>> 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.json')
>>> 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.json')
>>> 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
>>> os.remove('tmp.json')
calc_parameters()[source]

Postprocessing parameter calculation.

calculate_td_log()[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.

subcooling_dependents()[source]
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!

ttd_u_dependents()[source]
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.

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 desuperheater flowsheet 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 os
>>> nw = Network(
...     T_unit='C', p_unit='bar', h_unit='kJ / kg', v_unit='l / s',
...     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')
>>> 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.json')
>>> 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.json')
>>> round(cw_de.v.val, 2)
1.94
>>> et_de.set_attr(v=7)
>>> nw.solve('offdesign', init_path='tmp.json', design_path='tmp.json')
>>> round(cw_de.v.val, 2)
0.41
>>> os.remove('tmp.json')
get_mandatory_constraints()[source]
saturated_gas_dependents()[source]
saturated_gas_deriv(increment_filter, k, dependents=None)[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)\]

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.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 exchanger flowsheet 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 os
>>> 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.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.json')
>>> 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.json')
>>> 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.json')
>>> round(heat_sink.Q.val, 1)
-47275.8
>>> round(outg.T.val, 1)
140.0
>>> os.remove('tmp.json')
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)\]

calc_parameters()[source]

Postprocessing parameter calculation.

darcy_dependents()[source]
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} \]

energy_balance_dependents()[source]
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_connector_balance_func()[source]
energy_connector_dependents()[source]
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_bypass_constraints()[source]
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.).

hazen_williams_dependents()[source]
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}\)

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_dependents()[source]
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_group_dependents()[source]
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} \]

static outlets()[source]
powerinlets()[source]
poweroutlets()[source]

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 trough flowsheet 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 [23] 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 math
>>> 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')
>>> 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 * math.cos(aoi / 180 * math.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=10)
>>> 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 * math.cos(aoi / 180 * math.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)
3602817.0
calc_parameters()[source]

Postprocessing parameter calculation.

energy_group_dependents()[source]
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: [23].

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 collector flowsheet 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 os
>>> 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.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.json')
>>> round(sc.A.val, 1)
14.5
>>> sc.set_attr(A=sc.A.val, E=5e2, Tamb=20)
>>> nw.solve('offdesign', design_path='tmp.json')
>>> round(sc.Q.val, 1)
6083.8
>>> round(outg.T.val, 1)
70.5
>>> os.remove('tmp.json')
calc_parameters()[source]

Postprocessing parameter calculation.

energy_group_dependents()[source]
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: [24].

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 get_bypass_constraints()[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^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_dependents()[source]
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\]

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_structure_matrix(k)[source]

Calculate partial derivatives for all pressure equations.

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 separator flowsheet 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
>>> 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')
>>> 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
energy_balance_dependents()[source]
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}\]

fluid_structure_matrix(k)[source]

Calculate partial derivatives for all pressure equations.

Returns:

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

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]
static outlets()[source]
propagate_wrapper_to_target(branch)[source]
saturated_outlet_dependents(outconn=None, quality=None)[source]
saturated_outlet_deriv(increment_filter, k, dependents=None, outconn=None, quality=None)[source]
saturated_outlet_func(outconn=None, quality=None)[source]

Set the outlet state.

Returns:

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

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

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 drum flowsheet 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 os
>>> 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')
>>> 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('HeatExchanger', 'kA_char1', 'DEFAULT', CharLine)
>>> char2 = ldc('HeatExchanger', '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.assert_convergence()
>>> nw.save('tmp.json')
>>> 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.json')
>>> round(f_dr.m.val, 2)
0.58
>>> round(ev_amb.T.val - erp_ev.T.val ,1)
3.0
>>> os.remove('tmp.json')
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_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. The keys 1 and 2 connect the saturated liquid-vapor mixture of ‘in1’ with the saturated liquid (‘out1’) and saturated vapor (‘out2’), while the keys 3 and 4 connect the (superheated) gas of ‘in2’ with the same. The key 5 connects both saturated states.

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]
static outlets()[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 merge flowsheet 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
>>> 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)
>>> 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)

Consider a merge with three inlets which mixes three mass flows of the same fluid. In this case, the outlet mass flow will be the sum of both inlet mass flows and the outlet enthalpy will be the weighted sum of the inlet enthalpies. The pressure is equal for all connections of the merge imposed by the component’s mandatory constraints.

>>> T = 293.15
>>> inc1.set_attr(fluid={'O2': 1}, p=1, T=300, m=5)
>>> inc2.set_attr(fluid={'O2': 1}, T=450, m=5)
>>> inc3.set_attr(fluid={'O2': 1}, T=350, m=5)
>>> nw.solve('design')
>>> round(outg.m.val_SI, 1)
15.0
>>> round(outg.h.val_SI, 0)
334919.0
>>> round(outg.T.val_SI, 0)
367.0

We could also fix the outlet temperature and by that determine a missing mass flow, e.g. the hottest incoming stream.

>>> outg.set_attr(T=360)
>>> inc2.set_attr(m=None)
>>> nw.solve("design")
>>> round(inc2.m.val_SI, 1)
3.8

More interesting things can happen, if we want to take the fluid composition into account. For example, air (O2 + N2) is mixed with pure nitrogen and pure oxygen flows. At the outlet we want to have a new mixture with a fixed amount of nitrogen, e.g. 40 %. All gases enter the component at the same temperature. When changing the fluids, we have to rerun the network fluid detection, which is part of the topological setup. This usually only happens if you run a network with changed topology.

>>> T = 293.15
>>> inc1.reset_fluid_vector()
>>> inc2.reset_fluid_vector()
>>> inc3.reset_fluid_vector()
>>> outg.reset_fluid_vector()
>>> 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, m=None)
>>> outg.set_attr(fluid={'N2': 0.4}, T=None)
>>> nw.solve('design')
>>> m_expected = (
...     (inc1.fluid.val["O2"] * inc1.m.val_SI + inc2.m.val_SI)
...     / (1 - outg.fluid.val["N2"])
... )
>>> round(outg.m.val_SI, 2) == round(m_expected, 2)
True
>>> abs((outg.T.val_SI - T) / T) < 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((outg.T.val_SI - T) / T) < 0.01
True
energy_balance_dependents()[source]
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}\]

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_dependents()[source]
fluid_deriv(increment_filter, k, dependents=None)[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}\]

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 outlets()[source]
propagate_wrapper_to_target(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 splitter flowsheet 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
>>> 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)
>>> 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
energy_balance_dependents()[source]
energy_balance_deriv(increment_filter, k, dependents=None)[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}\]

fluid_dependents()[source]
fluid_deriv(increment_filter, k, dependents=None)[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}\]

get_mandatory_constraints()[source]
static get_parameters()[source]
static inlets()[source]
outlets()[source]
propagate_wrapper_to_target(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 splitter flowsheet 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
>>> 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)
>>> 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
energy_balance_deriv(increment_filter, k, dependents=None)[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}\]

enthalpy_structure_matrix(k)[source]

Calculate partial derivatives for energy balance equation.

Returns:

deriv (list) – Matrix of partial derivatives.

fluid_structure_matrix(k)[source]

Calculate partial derivatives for all pressure equations.

Returns:

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

get_mandatory_constraints()[source]
static get_parameters()[source]
static inlets()[source]
outlets()[source]
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 pipe flowsheet 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 os
>>> 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.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.json')
>>> 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.json')
>>> round(pi.pr.val, 2)
0.94
>>> os.remove('tmp.json')

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 valve flowsheet 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 os
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> v = Valve('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.json')
>>> 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.json')
>>> round(so_v.m.val, 1)
0.9
>>> round(v_si.T.val, 1)
30.0
>>> os.remove('tmp.json')
calc_parameters()[source]

Postprocessing parameter calculation.

dp_char_dependents()[source]
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)\]

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_bypass_constraints()[source]
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.power.bus module

Module of class PowerBus.

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/power/bus.py

SPDX-License-Identifier: MIT

class tespy.components.power.bus.PowerBus(label, **kwargs)[source]

Bases: Component

A PowerBus can hold any number incoming and outgoing power flows.

For example, it can be used to model single shaft gas turbine systems or to calculate the net power generation of a rankine cycle plant

Mandatory Equations

Inlets/Outlets

  • None

Optional inlets/outlets

  • specify number of inlets with num_in

  • specify number of outlets with num_out

Image

flowsheet of the power bus flowsheet of the power bus
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) – Number of inlets

  • num_out (float) – Number of outlets

Example

In a very simple example, a PowerBus is utilized to distribute power from the grid to 3 different consumers.

>>> from tespy.components import PowerSource, PowerSink, PowerBus
>>> from tespy.connections import PowerConnection
>>> from tespy.networks import Network
>>> import os
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)

We can add a PowerSource representing the grid and three PowerSink components representing different power demands.

>>> grid = PowerSource('grid')
>>> bus = PowerBus('power bus', num_in=1, num_out=3)
>>> demand1 = PowerSink('power demand 1')
>>> demand2 = PowerSink('power demand 2')
>>> demand3 = PowerSink('power demand 3')
>>> e1 = PowerConnection(grid, 'power', bus, 'power_in1')
>>> e2 = PowerConnection(bus, 'power_out1', demand1, 'power')
>>> e3 = PowerConnection(bus, 'power_out2', demand2, 'power')
>>> e4 = PowerConnection(bus, 'power_out3', demand3, 'power')
>>> nw.add_conns(e1, e2, e3, e4)

We have 4 variables (4 energy flows) and one equation (bus energy balance) in our system. That means, we have to fix three values of the variables, e.g. we can fix the three demand values:

>>> e2.set_attr(E=10e3)
>>> e3.set_attr(E=20e3)
>>> e4.set_attr(E=30e3)
>>> nw.solve('design')
>>> nw.assert_convergence()
>>> round(e1.E.val_SI) == 60000
True
energy_balance_dependents()[source]
energy_balance_func()[source]

Equation for energy balance of the component

Returns:

residual (float) – Residual value of equation

\[\begin{split}0=\sum_{i} \dot E_\text{i} - \sum_{o} \dot E_\text{o}\\ \forall i \in \text{inlets}, o \in \text{outlets}\end{split}\]

get_mandatory_constraints()[source]
get_parameters()[source]
powerinlets()[source]
poweroutlets()[source]

tespy.components.power.generator module

Module of class Generator.

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/power/generator.py

SPDX-License-Identifier: MIT

class tespy.components.power.generator.Generator(label, **kwargs)[source]

Bases: Component

A generator converts mechanical energy into electrical energy.

Mandatory Equations

  • None

Optional Equations

Inlets/Outlets

  • None

Optional inlets/outlets

  • power_in

  • power_out

Image

flowsheet of the generator flowsheet of the generator
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.

  • eta (float, dict) – Outlet to inlet efficiency, \(\eta/1\)

  • delta_power (float, dict) – Fixed power offset, :math:` ext{delta_power}/ ext{W}`

  • eta_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line for efficiency to power as function of design efficiency.

Example

A turbine generates mechanical power which is used to generate electrical power by the generator.

>>> from tespy.components import Sink, Source, Turbine, Generator, PowerSink
>>> from tespy.connections import Connection, PowerConnection
>>> from tespy.networks import Network
>>> import os
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> turbine = Turbine('turbine')

Steam flows through the turbine and we can set it up as we are used to for systems without power components.

>>> c1 = Connection(so, 'out1', turbine, 'in1')
>>> c2 = Connection(turbine, 'out1', si, 'in1')
>>> nw.add_conns(c1, c2)
>>> c1.set_attr(fluid={'water': 1}, T=500, p=50, m=1)
>>> c2.set_attr(p=5)
>>> turbine.set_attr(eta_s=0.9)
>>> nw.solve('design')

We can add the Generator and a PowerSink and then connect these parts to the turbine.

>>> generator = Generator('generator')
>>> power_sink = PowerSink('power sink')
>>> e1 = PowerConnection(turbine, 'power', generator, 'power_in')
>>> e2 = PowerConnection(generator, 'power_out', power_sink, 'power')
>>> nw.add_conns(e1, e2)

Now we have added two variables to our problem (the power flows of e1 and e2), but only one equation (the power balance for the turbine). The connection between the two power flows can be made through specifying the efficiency of the generator:

>>> generator.set_attr(eta=.98)
>>> nw.solve('design')
>>> nw.assert_convergence()
>>> round(e1.E.val_SI) == -round(turbine.P.val)
True
>>> round(e2.E.val_SI) == -round(turbine.P.val * 0.98)
True

We could also specify the electrical energy instead of fixing the steam mass flow to calculate the resulting steam mass flow:

>>> e2.set_attr(E=1e6)
>>> c1.set_attr(m=None)
>>> nw.solve('design')
>>> round(c1.m.val, 3)
1.837

Or, fix both (electrical and mechanical power flows) and leave open the generator efficiency:

>>> e1.set_attr(E=1.1e6)
>>> generator.set_attr(eta=None)
>>> nw.solve('design')
>>> round(generator.eta.val, 2)
0.91
>>> e1.set_attr(E=None)
>>> generator.set_attr(delta_power=50e3)
>>> nw.solve('design')
>>> round(generator.eta.val, 3)
0.952
calc_parameters()[source]

Postprocessing parameter calculation.

delta_power_dependents()[source]
delta_power_func()[source]

Equation for power delta of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} - \dot E_\text{out} - \Delta \dot E\]

delta_power_structure_matrix(k)[source]
eta_char_dependents()[source]
eta_char_func()[source]

Equation for efficiency characteristics of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} \cdot \eta_\text{design} \cdot f\left(\frac{\dot E_\text{out}}{\dot E_\text{out,design}}\right) - \dot E_\text{out}\]

eta_dependents()[source]
eta_func()[source]

Equation for efficiency of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} \cdot \eta - \dot E_\text{out}\]

eta_structure_matrix(k)[source]
get_parameters()[source]
powerinlets()[source]
poweroutlets()[source]

tespy.components.power.motor module

Module of class Motor.

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/power/motor.py

SPDX-License-Identifier: MIT

class tespy.components.power.motor.Motor(label, **kwargs)[source]

Bases: Component

A motor converts electrical energy into mechanical energy.

Mandatory Equations

  • None

Optional Equations

Inlets/Outlets

  • None

Optional inlets/outlets

  • power_in

  • power_out

Image

flowsheet of the motor flowsheet of the motor
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.

  • eta (float, dict) – Outlet to inlet efficiency, \(\eta/1\)

  • delta_power (float, dict) – Fixed power offset, :math:` ext{delta_power}/ ext{W}`

  • eta_char (tespy.tools.characteristics.CharLine, dict) – Characteristic line for efficiency to power as function of design efficiency.

Example

A compressor provides compressed air which is used in a compressed air distribution system. The energy is provided by an electrical motor.

>>> from tespy.components import Sink, Source, Compressor, Motor, PowerSource
>>> from tespy.connections import Connection, PowerConnection
>>> from tespy.networks import Network
>>> import os
>>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False)
>>> so = Source('source')
>>> si = Sink('sink')
>>> compressor = Compressor('compressor')

Ambient air flows into the compressor and is ejected at 4 bar. We can set the system up without the use of any of the power components.

>>> c1 = Connection(so, 'out1', compressor, 'in1')
>>> c2 = Connection(compressor, 'out1', si, 'in1')
>>> nw.add_conns(c1, c2)
>>> c1.set_attr(fluid={'air': 1}, T=25, p=1, m=1)
>>> c2.set_attr(p=4)
>>> compressor.set_attr(eta_s=0.8)
>>> nw.solve('design')

We can add the Motor and a PowerSource and then connect these parts to the compressor.

>>> motor = Motor('motor')
>>> power_source = PowerSource('power source')
>>> e1 = PowerConnection(power_source, 'power', motor, 'power_in')
>>> e2 = PowerConnection(motor, 'power_out', compressor, 'power')
>>> nw.add_conns(e1, e2)

Now we have added two variables to our problem (the power flows of e1 and e2), but only one equation (the power balance for the compressor). The connection between the two power flows can be made through specifying the efficiency of the motor:

>>> motor.set_attr(eta=.98)
>>> nw.solve('design')
>>> nw.assert_convergence()
>>> round(e2.E.val_SI) == round(compressor.P.val)
True
>>> round(e1.E.val_SI) == round(compressor.P.val / 0.98)
True

We could also specify the electrical energy instead of fixing the air mass flow to calculate the resulting air mass flow:

>>> e1.set_attr(E=1e5)
>>> c1.set_attr(m=None)
>>> nw.solve('design')
>>> round(c1.m.val, 3)
0.539

Or, fix both (electrical and mechanical power flows) and leave open the motor efficiency:

>>> e2.set_attr(E=0.9e5)
>>> motor.set_attr(eta=None)
>>> nw.solve('design')
>>> round(motor.eta.val, 2)
0.9
>>> e2.set_attr(E=None)
>>> motor.set_attr(delta_power=5e3)
>>> nw.solve('design')
>>> round(motor.eta.val, 3)
0.95
calc_parameters()[source]

Postprocessing parameter calculation.

delta_power_dependents()[source]
delta_power_func()[source]

Equation for power delta of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} - \dot E_\text{out} - \Delta \dot E\]

delta_power_structure_matrix(k)[source]
eta_char_dependents()[source]
eta_char_func()[source]

Equation for efficiency characteristics of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} \cdot \eta_\text{design} \cdot f\left(\frac{\dot E_\text{in}}{\dot E_\text{in,design}}\right) - \dot E_\text{out}\]

eta_dependents()[source]
eta_func()[source]

Equation for efficiency of the component

Returns:

residual (float) – Residual value of equation

\[0=\dot E_\text{in} \cdot \eta - \dot E_\text{out}\]

eta_structure_matrix(k)[source]
get_parameters()[source]
powerinlets()[source]
poweroutlets()[source]

tespy.components.power.sink module

Module of class PowerSink.

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/power/sink.py

SPDX-License-Identifier: MIT

class tespy.components.power.sink.PowerSink(label, **kwargs)[source]

Bases: Component

A power flow drains in a PowerSink.

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 PowerSink and specify a label.

>>> from tespy.components import PowerSink
>>> si = PowerSink('a labeled sink')
>>> si.label
'a labeled sink'
static get_mandatory_constraints()[source]
static powerinlets()[source]

tespy.components.power.source module

Module of class PowerSource.

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/power/source.py

SPDX-License-Identifier: MIT

class tespy.components.power.source.PowerSource(label, **kwargs)[source]

Bases: Component

A power flow emerges from a PowerSource.

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 PowerSource and specify a label.

>>> from tespy.components import PowerSource
>>> so = PowerSource('a labeled source')
>>> so.label
'a labeled source'
static get_mandatory_constraints()[source]
static poweroutlets()[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
>>> nw = Network(T_unit='C', p_unit='bar', v_unit='l / s', iterinfo=False)
>>> fc = FuelCell('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 produces 200kW of electrical power 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 temperature of the water at the outlet should be 50 °C. The cooling fluid is pure water and is heated up from 25 °C to 40 °C.

>>> fc.set_attr(eta=0.45, P=-200e03, pr=0.9)
>>> cw_in.set_attr(T=25, p=1, fluid={'H2O': 1})
>>> cw_out.set_attr(T=40)
>>> oxygen_in.set_attr(T=25, p=1)
>>> hydrogen_in.set_attr(T=25)
>>> water_out.set_attr(T=50)
>>> nw.solve('design')
>>> round(cw_in.m.val, 1)
10.2
>>> Q = fc.Q.val / 1e3
>>> round(Q, 0)
-642.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.

cooling_fluid_func()[source]
cooling_fluid_structure_matrix(k)[source]
cooling_mass_flow_func()[source]
cooling_mass_flow_structure_matrix(k)[source]
energy_balance_dependents()[source]
energy_balance_deriv(increment_filter, k, dependents=None)[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.

eta_dependents()[source]
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\]

static get_bypass_constraints()[source]
get_mandatory_constraints()[source]
get_parameters()[source]
get_variables()[source]
heat_dependents()[source]
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)\]

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 outlets()[source]
propagate_wrapper_to_target(branch)[source]
reactor_mass_flow_dependents()[source]
reactor_mass_flow_deriv(increment_filter, k, dependents=None)[source]

Calculate the partial derivatives for all mass flow balance equations.

Returns:

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

reactor_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}\]

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_structure_matrix(k)[source]

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equations.

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

specific_energy_dependents()[source]
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\]

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 electrolyzer flowsheet 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 os
>>> 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')

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.json')
>>> round(el.e0 / el.P.val * el_cmp.m.val_SI, 1)
0.8
>>> P_design = el.P.val
>>> round(P_design / 1e6, 1)
13.2
>>> nw.solve('offdesign', design_path='tmp.json')
>>> round(el.eta.val, 1)
0.8
>>> el_cmp.set_attr(v=None)
>>> el.set_attr(P=P_design * 0.2)
>>> nw.solve('offdesign', design_path='tmp.json')
>>> round(el.eta.val, 2)
0.84
>>> os.remove('tmp.json')
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}\]

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.

cooling_fluid_func()[source]
cooling_fluid_structure_matrix(k)[source]
cooling_mass_flow_func()[source]
cooling_mass_flow_structure_matrix(k)[source]
energy_balance_dependents()[source]
energy_balance_deriv(increment_filter, k, dependents=None)[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.

eta_char_dependents()[source]
eta_char_deriv(increment_filter, k, dependents=None)[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_dependents()[source]
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\]

exergy_balance(T0)[source]

Exergy balance calculation method.

Parameters:

T0 (float) – Ambient temperature T0 / K.

gas_temperature_dependents()[source]
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}\]

static get_bypass_constraints()[source]
get_mandatory_constraints()[source]
get_parameters()[source]
get_variables()[source]
heat_dependents()[source]
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)\]

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 outlets()[source]
propagate_wrapper_to_target(branch)[source]
reactor_mass_flow_dependents()[source]
reactor_mass_flow_deriv(increment_filter, k, dependents=None)[source]

Calculate the partial derivatives for all mass flow balance equations.

Returns:

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

reactor_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}\]

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_structure_matrix(k)[source]

Equations for reactor pressure balance.

Returns:

residual (list) – Residual values of equations.

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

specific_energy_dependents()[source]
specific_energy_func()[source]

Equation for specific energy consumption.

Returns:

residual (float) – Residual value of equation.

\[0 = P - \dot{m}_{H_2,out3} \cdot e\]

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 compressor flowsheet 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 os
>>> 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')
>>> 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.json')
>>> round(comp.P.val, 0)
12772.0
>>> round(comp.eta_s.val, 2)
0.8
>>> inc.set_attr(v=45)
>>> comp.set_attr(igva='var')
>>> nw.solve('offdesign', design_path='tmp.json')
>>> round(comp.eta_s.val, 2)
0.77
>>> os.remove('tmp.json')
calc_parameters()[source]

Postprocessing parameter calculation.

char_map_dependents()[source]
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 [25].

\[\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_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 [25].

\[\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}\]
check_parameter_bounds()[source]

Check parameter value limits.

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.

energy_connector_balance_func()[source]

(optional) energy balance equation connecting the power connector to the component’s power

Returns:

residual (float) – Residual value of equation

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

energy_connector_dependents()[source]
eta_s_char_dependents()[source]
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_dependents()[source]
eta_s_deriv(increment_filter, k, dependents=None)[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)\]

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_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} 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}\]

static powerinlets()[source]

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 pump flowsheet 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 os
>>> 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')
>>> 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.json')
>>> 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.json')
>>> round(pu.eta_s.val, 2)
0.71
>>> round(inc.v.val, 1)
0.9
>>> os.remove('tmp.json')
calc_parameters()[source]

Postprocessing parameter calculation.

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.

energy_connector_balance_func()[source]

(optional) energy balance equation connecting the power connector to the component’s power

Returns:

residual (float) – Residual value of equation

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

energy_connector_dependents()[source]
eta_s_char_dependents()[source]
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_dependents()[source]
eta_s_deriv(increment_filter, k, dependents=None)[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.

Returns:

residual (float) – Residual value of equation.

\[0 = -\left( h_{out} - h_{in} \right) \cdot \eta_{s} + \left( h_{out,s} - h_{in} \right)\]

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_dependents()[source]
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)\]

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} 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}\]

static powerinlets()[source]

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.

The component Turbine is the parent class for the components:

  • tespy.components.turbomachinery.steam_turbine.SteamTurbine

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 turbine flowsheet 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 os
>>> nw = Network(p_unit='bar', T_unit='C', h_unit='kJ / kg', iterinfo=False)
>>> si = Sink('sink')
>>> so = Source('source')
>>> t = Turbine('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.json')
>>> 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.json')
>>> round(t.eta_s.val, 3)
0.898
>>> round(inc.p.val, 1)
88.6
>>> os.remove('tmp.json')
calc_eta_s()[source]
calc_parameters()[source]

Postprocessing parameter calculation.

cone_dependents()[source]
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}\]

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.

energy_connector_balance_func()[source]

(optional) energy balance equation connecting the power connector to the component’s power

Returns:

residual (float) – Residual value of equation

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

energy_connector_dependents()[source]
eta_s_char_dependents()[source]
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_dependents()[source]
eta_s_deriv(increment_filter, k, dependents=None)[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}\]

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_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^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}\]

static poweroutlets()[source]

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)\]

calc_parameters()[source]

Postprocessing parameter calculation.

energy_balance_dependents()[source]
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\]

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_bypass_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.).

static inlets()[source]
static outlets()[source]