Skip to content

Commit

Permalink
Fix a critical bug in jacobian for specified power in turbomachinery
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Nov 21, 2023
1 parent 140659c commit 7d0fa9f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/tespy/components/turbomachinery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,17 @@ def energy_balance_deriv(self, increment_filter, k):
k : int
Position of derivatives in Jacobian matrix (k-th equation).
"""
self.jacobian[k, 0, 0] = self.outl[0].h.val_SI - self.inl[0].h.val_SI
self.jacobian[k, 0, 2] = -self.inl[0].m.val_SI
self.jacobian[k, 1, 2] = self.inl[0].m.val_SI
i = self.inl[0]
o = self.outl[0]
if i.m.is_var:
self.jacobian[k, i.m.J_col] = o.h.val_SI - i.h.val_SI
if i.h.is_var:
self.jacobian[k, i.h.J_col] = -i.m.val_SI
if o.h.is_var:
self.jacobian[k, o.h.J_col] = i.m.val_SI
# custom variable P
if self.P.is_var:
self.jacobian[k, self.P.J_col] = -1

def bus_func(self, bus):
r"""
Expand Down

0 comments on commit 7d0fa9f

Please sign in to comment.