tespy.components.power package¶
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:
ComponentA 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
PowerConnection inlets/outlets
specify number of inlets with
num_in: ‘power_in1’, …specify number of outlets with
num_out‘power_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) – 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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... })
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
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:
ComponentA generator converts mechanical energy into electrical energy.
Mandatory Equations
None
Optional Equations
Inlets/Outlets
None
Optional inlets/outlets
power_in
power_out
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.
eta (float, dict) – Outlet to inlet efficiency, \(\eta/1\)
delta_power (float, dict) – Fixed power offset, \(\text{delta_power}/\text{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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... }) >>> 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
- 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\]
- 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}\]
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:
ComponentA motor converts electrical energy into mechanical energy.
Mandatory Equations
None
Optional Equations
Inlets/Outlets
None
Optional inlets/outlets
power_in
power_out
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.
eta (float, dict) – Outlet to inlet efficiency, \(\eta/1\)
delta_power (float, dict) – Fixed power offset, \(\text{delta_power}/\text{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(iterinfo=False) >>> nw.units.set_defaults(**{ ... "pressure": "bar", "temperature": "degC" ... }) >>> 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
- 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\]
- 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}\]
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:
ComponentA 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'
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:
ComponentA 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'