Source code for tespy.components.basics.cycle_closer
# -*- coding: utf-8"""Module for class CycleCloserThis file is part of project TESPy (github.com/oemof/tespy). It's copyrightedby the contributors recorded in the version control history of the file,available from its original location tespy/components/basics/cycle_closer.pySPDX-License-Identifier: MIT"""importnumpyasnpfromtespy.components.componentimportComponentfromtespy.components.componentimportcomponent_registryfromtespy.tools.data_containersimportComponentPropertiesasdc_cp
[docs]@component_registryclassCycleCloser(Component):r""" Component for closing cycles. **Mandatory Equations** - :py:meth:`tespy.components.basics.cycle_closer.CycleCloser.pressure_equality_func` - :py:meth:`tespy.components.basics.cycle_closer.CycleCloser.enthalpy_equality_func` Image not available Parameters ---------- label : str The label of the component. design : list List containing design parameters (stated as String). offdesign : list List containing offdesign parameters (stated as String). design_path : str Path to the components design case. local_offdesign : boolean Treat this component in offdesign mode in a design calculation. local_design : boolean Treat this component in design mode in an offdesign calculation. char_warnings : boolean Ignore warnings on default characteristics usage for this component. printout : boolean Include this component in the network's results printout. Note ---- This component can be used to close a cycle process. The system of equations describing your plant will overdetermined, if you close a cycle without this component or a cut the cycle with a sink and a source at some point of the cycle. This component can be used instead of cutting the cycle. Example ------- Create a cycle containing a pump and a pipe. The pump increases pressure the pipe cools the liquid and destroys the pressure rise. The heat extracted at the pipe must be the same value of the power input at the pump (but negative), as there is no other in- or outputs of energy in the system. >>> from tespy.components import CycleCloser, Pipe, Pump >>> from tespy.connections import Connection >>> from tespy.networks import Network >>> nw = Network(p_unit='bar', T_unit='C', iterinfo=False) >>> pi = Pipe('pipe') >>> pu = Pump('pump') >>> cc = CycleCloser('cycle closing component') >>> cc.component() 'cycle closer' >>> pu_pi = Connection(pu, 'out1', pi, 'in1') >>> pi_cc = Connection(pi, 'out1', cc, 'in1') >>> cc_pu = Connection(cc, 'out1', pu, 'in1') >>> nw.add_conns(pu_pi, pi_cc, cc_pu) >>> pi_cc.set_attr(p=1, T=20, fluid={'water': 1}) >>> pu_pi.set_attr(p=10) >>> pu.set_attr(eta_s=0.8, P=1000) >>> nw.solve('design') >>> round(pi.Q.val, 1) == -round(pu.P.val, 1) True """
[docs]defcalc_parameters(self):r"""Postprocessing parameter calculation."""# calculate deviation in mass flowself.mass_deviation.val=abs(self.inl[0].m.val_SI-self.outl[0].m.val_SI)# calculate deviation in fluid compositiond1=self.inl[0].fluid.vald2=self.outl[0].fluid.valdiff=[d1[key]-d2[key]forkeyind1.keys()]self.fluid_deviation.val=np.linalg.norm(diff)