tespy.components.nodes package¶
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:
ComponentClass NodeBase is parent class for all components of submodule nodes.
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:
NodeBaseSeparate liquid phase from gas phase of a single fluid.
This component is the parent component of the Drum.
Mandatory Equations
tespy.components.nodes.base.NodeBase.pressure_structure_matrix()tespy.components.nodes.droplet_separator.DropletSeparator.fluid_structure_matrix()tespy.components.nodes.droplet_separator.DropletSeparator.energy_balance_func()saturated liquid:
tespy.components.nodes.droplet_separator.DropletSeparator.saturated_outlet_func()saturated gas:
tespy.components.nodes.droplet_separator.DropletSeparator.saturated_outlet_func()
Inlets/Outlets
in1
out1, out2 (index 1: saturated liquid, index 2: saturated gas)
Image
- 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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC", "enthalpy": "kJ/kg" ... }) >>> 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_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]¶
Set the fluid strucutre matrix to force fluid composition equality.
- 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_isolinemethod of theFluidPropertyDiagramclass. First level keys are the connection index (‘in1’ -> ‘out1’, therefore1etc.).
- 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.
- 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}\]
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:
DropletSeparatorA drum separates saturated gas from saturated liquid.
Mandatory Equations
tespy.components.nodes.base.NodeBase.pressure_structure_matrix()tespy.components.nodes.droplet_separator.DropletSeparator.fluid_structure_matrix()tespy.components.nodes.droplet_separator.DropletSeparator.energy_balance_func()saturated liquid:
tespy.components.nodes.droplet_separator.DropletSeparator.saturated_outlet_func()saturated gas:
tespy.components.nodes.droplet_separator.DropletSeparator.saturated_outlet_func()
Inlets/Outlets
in1, in2 (index 1: from economiser, index 2: from evaporator)
out1, out2 (index 1: saturated liquid, index 2: saturated gas)
Image
- 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_charfrom 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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC", "enthalpy": "kJ/kg" ... }) >>> 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_isolinemethod of theFluidPropertyDiagramclass. The keys1and2connect the saturated liquid-vapor mixture of ‘in1’ with the saturated liquid (‘out1’) and saturated vapor (‘out2’), while the keys3and4connect the (superheated) gas of ‘in2’ with the same. The key5connects both saturated states.
- 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.
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:
NodeBaseClass for merge points with multiple inflows and one outflow.
Mandatory Equations
Inlets/Outlets
specify number of inlets with
num_in(default value: 2)out1
Image
- 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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar" ... }) >>> 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_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_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_plotting_data()[source]¶
Generate a dictionary containing FluProDia plotting information.
- Returns:
data (dict) – A nested dictionary containing the keywords required by the
calc_individual_isolinemethod of theFluidPropertyDiagramclass. First level keys are the connection index (‘in1’ -> ‘out1’, therefore1etc.).
tespy.components.nodes.node module¶
Module of class Node.
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/node.py
SPDX-License-Identifier: MIT
- class tespy.components.nodes.node.Node(label, **kwargs)[source]¶
-
Class for combined merge and splitting points with multiple inflows and outflows.
Mandatory Equations
tespy.components.nodes.base.NodeBase.pressure_structure_matrix()tespy.components.nodes.node.Node.enthalpy_structure_matrix()
Inlets/Outlets
specify number of inlets with
num_in(default value: 2)specify number of outlets with
num_in(default value: 2)
Image
- 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 for this component, default value: 2.
num_out (float) – Number of outlets for this component, default value: 2.
Example
The
Nodeserves as a splitter and a merger at the same time. For example, you can use it to represent a preheating vessel, which produces saturated liquid water by mixing pumped condensate and a steam stream. The saturated liquid is then split into a specified amount of outlet streams. In this example it will be just two.>>> from tespy.components import Source, Sink, Node >>> from tespy.connections import Connection >>> from tespy.networks import Network >>> nw = Network(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... }) >>> so1 = Source("source1") >>> so2 = Source("source2") >>> si1 = Sink("sink1") >>> si2 = Sink("sink2") >>> node = Node("node") >>> node.set_attr(num_in=2, num_out=2) >>> c1 = Connection(so1, "out1", node, "in1", label="pumped condensate") >>> c2 = Connection(so2, "out1", node, "in2", label="extraction steam") >>> c3 = Connection(node, "out1", si1, "in1", label="outlet 1") >>> c4 = Connection(node, "out2", si2, "in1", label="outlet 2") >>> nw.add_conns(c1, c2, c3, c4)
We can parametrize the system, for example, to preheat 50 kg/s of water. The system will then identify, what amout of extraction steam is required to preheat the water to the saturated liquid state. Apart from the inlet states we have to add one mass flow specification to define the split ratio between the two outlets.
Note
The enthalpy of the fluid will be identical at all exits. If you want to have separation of phasey, you have to use a DropletSeparator downstream of this component.
>>> c1.set_attr(fluid={"water": 1}, m=50, p=3, T=50) >>> c2.set_attr(fluid={"water": 1}, T=200) >>> c3.set_attr(x=0) >>> c4.set_attr(m=1) >>> nw.solve("design")
- enthalpy_structure_matrix(k)[source]¶
Set up the structure matrix for the outlet enthalpy constraints:
All outlet enthalpy values must be identical.
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:
NodeBaseA separator separates fluid components from a mass flow.
Mandatory Equations
tespy.components.nodes.base.NodeBase.pressure_structure_matrix()tespy.components.nodes.separator.Separator.energy_balance_func()
Inlets/Outlets
in1
specify number of outlets with
num_out(default value: 2)
Image
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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... }) >>> 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_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_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}\]
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:
NodeBaseSplit up a mass flow in parts of identical enthalpy and fluid composition.
Mandatory Equations
tespy.components.nodes.base.NodeBase.pressure_structure_matrix()tespy.components.nodes.splitter.Splitter.enthalpy_structure_matrix()tespy.components.nodes.splitter.Splitter.fluid_structure_matrix()
Inlets/Outlets
in1
specify number of outlets with
num_out(default value: 2)
Image
- 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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... }) >>> 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
- enthalpy_structure_matrix(k)[source]¶
Calculate partial derivatives for energy balance equation.
- Returns:
deriv (list) – Matrix of partial derivatives.