Skip to content

Commit

Permalink
Switched sign for value referencing of delta to match docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Dec 7, 2023
1 parent 5ebb583 commit 9739a9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/tespy/connections/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def primary_ref_func(self, k, **kwargs):
ref = self.get_attr(f"{variable}_ref").ref
self.residual[k] = (
self.get_attr(variable).val_SI
- ref.obj.get_attr(variable).val_SI * ref.factor + ref.delta_SI
- (ref.obj.get_attr(variable).val_SI * ref.factor + ref.delta_SI)
)

def primary_ref_deriv(self, k, **kwargs):
Expand Down Expand Up @@ -761,7 +761,7 @@ def T_deriv(self, k, **kwargs):
def T_ref_func(self, k, **kwargs):
ref = self.T_ref.ref
self.residual[k] = (
self.calc_T() - ref.obj.calc_T() * ref.factor + ref.delta_SI
self.calc_T() - (ref.obj.calc_T() * ref.factor + ref.delta_SI)
)

def T_ref_deriv(self, k, **kwargs):
Expand Down Expand Up @@ -810,7 +810,7 @@ def v_ref_func(self, k, **kwargs):
ref = self.v_ref.ref
self.residual[k] = (
self.calc_vol(T0=self.T.val_SI) * self.m.val_SI
- ref.obj.calc_vol(T0=ref.obj.T.val_SI) * ref.obj.m.val_SI * ref.factor + ref.delta_SI
- (ref.obj.calc_vol(T0=ref.obj.T.val_SI) * ref.obj.m.val_SI * ref.factor + ref.delta_SI)
)

def v_ref_deriv(self, k, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_volumetric_flow_reference(self):
c2.set_attr(v=Ref(c1, 2, 10))
self.nw.solve('design')

v_expected = round(c1.v.val * 2 - 10, 4)
v_expected = round(c1.v.val * 2 + 10, 4)
v_is = round(c2.v.val, 4)
msg = (
'The mass flow of the connection 2 should be equal to '
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_temperature_reference(self):
c2.set_attr(T=Ref(c1, 1.5, -75))
self.nw.solve('design')

T_expected = round(convert_from_SI("T", c1.T.val_SI * 1.5, c1.T.unit) + 75, 4)
T_expected = round(convert_from_SI("T", c1.T.val_SI * 1.5, c1.T.unit) - 75, 4)
T_is = round(c2.T.val, 4)
msg = (
'The temperature of the connection 2 should be equal to '
Expand Down Expand Up @@ -116,7 +116,7 @@ def test_primary_reference(self):
c2.set_attr(m=Ref(c1, 2, -0.5))
self.nw.solve('design')

m_expected = round(convert_from_SI("m", c1.m.val_SI * 2, c1.m.unit) + 0.5, 4)
m_expected = round(convert_from_SI("m", c1.m.val_SI * 2, c1.m.unit) - 0.5, 4)
m_is = round(c2.m.val, 4)
msg = (
'The mass flow of the connection 2 should be equal to '
Expand Down

0 comments on commit 9739a9f

Please sign in to comment.