Skip to content

Commit

Permalink
Merge 81145ae into 4aecead
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jan 11, 2021
2 parents 4aecead + 81145ae commit 9bd6c97
Show file tree
Hide file tree
Showing 40 changed files with 6,392 additions and 5,061 deletions.
10 changes: 9 additions & 1 deletion docs/api/tespy.components.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,22 @@ tespy.components.heat_exchangers.solar_collector module
:undoc-members:
:show-inheritance:

tespy.components.nodes.base module
--------------------------------------

.. automodule:: tespy.components.nodes.base
:members:
:undoc-members:
:show-inheritance:


tespy.components.nodes.droplet_separator module
-----------------------------------------------

.. automodule:: tespy.components.nodes.droplet_separator
:members:
:undoc-members:
:show-inheritance:

tespy.components.nodes.drum module
----------------------------------

Expand Down
103 changes: 73 additions & 30 deletions src/tespy/components/basics/cycle_closer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ class CycleCloser(Component):
r"""
Component for closing cycles.
Equations
**Mandatory Equations**
**mandatory equations**
.. math::
0 = p_{in} - p_{out}
0 = h_{in} - h_{out}
- :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
Expand Down Expand Up @@ -118,43 +113,91 @@ def outlets():

def comp_init(self, nw):

Component.comp_init(self, nw)

# number of mandatroy equations for
# pressure: 1
# enthalpy: 1
self.num_eq = 2
Component.comp_init(self, nw, num_eq=2)

self.jacobian = np.zeros((
self.num_eq,
self.num_i + self.num_o + self.num_vars,
self.num_nw_vars))

self.residual = np.ones(self.num_eq)
# derivatives for pressure
self.jacobian[0, 0, 1] = 1
self.jacobian[0, 1, 1] = -1
# derivatives for enthalpy
self.jacobian[1, 0, 2] = 1
self.jacobian[1, 1, 2] = -1

def equations(self):
r"""Calculate residual vector with results of equations."""
k = 0
def mandatory_equations(self, doc=False):
r"""
Calculate residual vector of mandatory equations.
Parameters
----------
doc : boolean
Return equation in LaTeX format instead of value.
Returns
-------
k : int
Position of last equation in residual value vector (k-th equation).
"""
######################################################################
# equation for pressure
self.residual[k] = self.inl[0].p.val_SI - self.outl[0].p.val_SI
k += 1

self.residual[0] = self.pressure_equality_func()
if doc:
self.equation_docs[0:1] = self.pressure_equality_func(doc=doc)
######################################################################
# equation for enthalpy
self.residual[k] = self.inl[0].h.val_SI - self.outl[0].h.val_SI
k += 1
self.residual[1] = self.enthalpy_equality_func()
if doc:
self.equation_docs[1:2] = self.enthalpy_equality_func(doc=doc)
return 2

def derivatives(self, vek_z):
r"""Calculate partial derivatives for given equations."""
######################################################################
# all derivatives are static
def pressure_equality_func(self, doc=False):
r"""
Equation for pressure equality.
Parameters
----------
doc : boolean
Return equation in LaTeX format instead of value.
Returns
-------
residual : float
Residual value of equation.
.. math::
0=p_{in}-p_{out}
"""
if not doc:
return self.inl[0].p.val_SI - self.outl[0].p.val_SI
else:
latex = r'0=p_\mathrm{in}-p_\mathrm{out}'
return [self.generate_latex(latex, 'pressure_equality_func')]

def enthalpy_equality_func(self, doc=False):
r"""
Equation for enthalpy equality.
Parameters
----------
doc : boolean
Return equation in LaTeX format instead of value.
Returns
-------
residual : float
Residual value of equation.
.. math::
0=h_{in}-h_{out}
"""
if not doc:
return self.inl[0].h.val_SI - self.outl[0].h.val_SI
else:
latex = r'0=h_\mathrm{in}-h_\mathrm{out}'
return [self.generate_latex(latex, 'enthalpy_equality_func')]

def propagate_fluid_to_target(self, inconn, start):
r"""
Expand Down Expand Up @@ -187,7 +230,7 @@ def propagate_fluid_to_source(self, outconn, start):
return

def calc_parameters(self):

r"""Postprocessing parameter calculation."""
# calculate deviation in mass flow
self.mass_deviation.val = np.abs(
self.inl[0].m.val_SI - self.outl[0].m.val_SI)
Expand Down
4 changes: 0 additions & 4 deletions src/tespy/components/basics/sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class Sink(Component):
r"""
A flow drains in a Sink.
Equations
This component is unconstrained.
Parameters
----------
label : str
Expand Down
4 changes: 0 additions & 4 deletions src/tespy/components/basics/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class Source(Component):
r"""
A flow originates from a Source.
Equations
This component is unconstrained.
Parameters
----------
label : str
Expand Down
Loading

0 comments on commit 9bd6c97

Please sign in to comment.