Source code for tespy.components.displacementmachinery.base
# -*- coding: utf-8
"""Module of class DisplacementMachine.
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/displacementmachinery/base.py
SPDX-License-Identifier: MIT
"""
from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools.data_containers import ComponentMandatoryConstraints as dc_cmc
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.helpers import _numeric_deriv
[docs]
@component_registry
class DisplacementMachine(Component):
r"""
Parent class for displacement machines
**Mandatory Equations**
- mass flow: :py:meth:`tespy.components.component.Component.variable_equality_structure_matrix`
- fluid: :py:meth:`tespy.components.component.Component.variable_equality_structure_matrix`
**Optional Equations**
- :py:meth:`tespy.components.component.Component.pr_structure_matrix`
- :py:meth:`tespy.components.component.Component.dp_structure_matrix`
- :py:meth:`tespy.components.displacementmachinery.base.DisplacementMachine.energy_balance_func`
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, :math:`P/\text{W}`
pr : float, dict
Outlet to inlet pressure ratio, :math:`pr/1`
dp : float, dict
Inlet to outlet pressure difference, :math:`dp/\text{p}_\text{unit}`
Is specified in the Network's pressure unit
Example
-------
For an example please refer to:
- :class:`tespy.components.displacementmachinery.polynomial_compressor.PolynomialCompressor`
- :class:`tespy.components.displacementmachinery.polynomial_compressor_with_cooling.PolynomialCompressorWithCooling`
"""
def _calc_P(self):
return self.inl[0].m.val_SI * (self.outl[0].h.val_SI - self.inl[0].h.val_SI)
[docs]
def get_parameters(self):
return {
'P': dc_cp(
num_eq_sets=1,
func=self.energy_balance_func,
dependents=self.energy_balance_dependents,
quantity="power",
description="power input of the component",
calc=self._calc_P
),
'pr': dc_cp(
num_eq_sets=1,
func_params={'pr': 'pr'},
structure_matrix=self.pr_structure_matrix,
quantity="ratio",
description="outlet to inlet pressure ratio",
calc=self._calc_pr
),
'dp': dc_cp(
num_eq_sets=1,
structure_matrix=self.dp_structure_matrix,
func_params={'dp': 'dp'},
quantity="pressure_difference",
description="inlet to outlet absolute pressure change",
calc=self._calc_dp
)
}
[docs]
def get_bypass_constraints(self):
return {
'mass_flow_constraints': dc_cmc(**{
'structure_matrix': self.variable_equality_structure_matrix,
'num_eq_sets': self.num_i,
'func_params': {'variable': 'm'}
}),
'pressure_constraints': dc_cmc(**{
'structure_matrix': self.variable_equality_structure_matrix,
'num_eq_sets': self.num_i,
'func_params': {'variable': 'p'}
}),
'enthalpy_constraints': dc_cmc(**{
'structure_matrix': self.variable_equality_structure_matrix,
'num_eq_sets': self.num_i,
'func_params': {'variable': 'h'}
}),
'fluid_constraints': dc_cmc(**{
'structure_matrix': self.variable_equality_structure_matrix,
'num_eq_sets': self.num_i,
'func_params': {'variable': 'fluid'}
})
}
[docs]
@staticmethod
def inlets():
return ['in1']
[docs]
@staticmethod
def outlets():
return ['out1']
[docs]
def energy_balance_func(self):
r"""
Calculate energy balance of a turbomachine.
Returns
-------
residual : float
Residual value of turbomachine energy balance
.. math::
0=\dot{m}_{in}\cdot\left(h_{out}-h_{in}\right)-P
"""
return self._calc_P() - self.P.val_SI
[docs]
def energy_balance_dependents(self):
return [
self.inl[0].m,
self.inl[0].h,
self.outl[0].h,
]
[docs]
def entropy_balance(self):
r"""
Calculate entropy balance of turbomachine.
Note
----
The entropy balance makes the following parameter available:
.. math::
\text{S\_irr}=\dot{m} \cdot \left(s_\text{out}-s_\text{in}
\right)\\
"""
self.S_irr = self.inl[0].m.val_SI * (
self.outl[0].s.val_SI - self.inl[0].s.val_SI
)
[docs]
def get_plotting_data(self):
"""Generate a dictionary containing FluProDia plotting information.
Returns
-------
data : dict
A nested dictionary containing the keywords required by the
:code:`calc_individual_isoline` method of the
:code:`FluidPropertyDiagram` class. First level keys are the
connection index ('in1' -> 'out1', therefore :code:`1` etc.).
"""
return {
1: {
'isoline_property': 's',
'isoline_value': self.inl[0].s.val,
'isoline_value_end': self.outl[0].s.val,
'starting_point_property': 'vol',
'starting_point_value': self.inl[0].vol.val,
'ending_point_property': 'vol',
'ending_point_value': self.outl[0].vol.val
}
}