From 9739a9f08e5e03695723478f3f3c78ce06da8eed Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Thu, 7 Dec 2023 18:55:03 +0100 Subject: [PATCH] Switched sign for value referencing of delta to match docs --- src/tespy/connections/connection.py | 6 +++--- tests/test_connections.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tespy/connections/connection.py b/src/tespy/connections/connection.py index ceb64a66f..459bcd14b 100644 --- a/src/tespy/connections/connection.py +++ b/src/tespy/connections/connection.py @@ -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): @@ -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): @@ -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): diff --git a/tests/test_connections.py b/tests/test_connections.py index acc620a20..6d35bdf80 100644 --- a/tests/test_connections.py +++ b/tests/test_connections.py @@ -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 ' @@ -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 ' @@ -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 '