Skip to content

Commit

Permalink
Assert lengths of m_flow and cp vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
MassimoCimmino committed Jul 13, 2021
1 parent 281af54 commit 114c77b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pygfunction/pipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,9 @@ def _format_inputs(self, m_flow, cp, nSegments):
# Format mass flow rate inputs
# Mass flow rate in each fluid circuit
m_flow_in = np.atleast_1d(m_flow)
if not len(m_flow_in) == self.nInlets:
raise ValueError(
'Incorrect length of mass flow vector.')
self._m_flow_in = m_flow_in
# Mass flow rate in pipes
m_flow_pipe = np.tile(m_flow_in, 2)
Expand All @@ -1745,6 +1748,11 @@ def _format_inputs(self, m_flow, cp, nSegments):
# Format heat capacity inputs
# Heat capacity in each fluid circuit
cp_in = np.atleast_1d(cp)
if len(cp_in) == 1:
cp_in = np.tile(cp, self.nInlets)
elif not len(cp_in) == self.nInlets:
raise ValueError(
'Incorrect length of heat capacity vector.')
self._cp_in = cp_in
# Heat capacity in pipes
cp_pipe = np.tile(cp_in, 2)
Expand Down

0 comments on commit 114c77b

Please sign in to comment.