From 9520ee6c90235787fcd05e58b4368668161af9b5 Mon Sep 17 00:00:00 2001 From: c-ortbauer <111966242+c-ortbauer@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:56:32 +0100 Subject: [PATCH 1/3] Fix HumidAir.mixing Fixes the calculated humidity when mixing two HumidAir states. --- pyfluids/humid_air/humid_air.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyfluids/humid_air/humid_air.py b/pyfluids/humid_air/humid_air.py index 266a1d0..8446cae 100644 --- a/pyfluids/humid_air/humid_air.py +++ b/pyfluids/humid_air/humid_air.py @@ -475,9 +475,16 @@ def mixing( InputHumidAir.humidity( ( first_specific_mass_flow * first.humidity + + first_specific_mass_flow * first.humidity * second.humidity + second_specific_mass_flow * second.humidity + + second_specific_mass_flow * first.humidity * second.humidity + ) + / ( + first_specific_mass_flow + + first_specific_mass_flow * second.humidity + + second_specific_mass_flow + + second_specific_mass_flow * first.humidity ) - / (first_specific_mass_flow + second_specific_mass_flow) ), ) From ec9f308e6ff05e3895f0ad8db476374bb2a761c1 Mon Sep 17 00:00:00 2001 From: Vladimir Portyanikhin <86243191+portyanikhin@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:35:52 +0300 Subject: [PATCH 2/3] Refactoring --- pyfluids/humid_air/humid_air.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pyfluids/humid_air/humid_air.py b/pyfluids/humid_air/humid_air.py index 8446cae..b7a403c 100644 --- a/pyfluids/humid_air/humid_air.py +++ b/pyfluids/humid_air/humid_air.py @@ -474,16 +474,12 @@ def mixing( ), InputHumidAir.humidity( ( - first_specific_mass_flow * first.humidity - + first_specific_mass_flow * first.humidity * second.humidity - + second_specific_mass_flow * second.humidity - + second_specific_mass_flow * first.humidity * second.humidity + first_specific_mass_flow * first.humidity * (1 + second.humidity) + + second_specific_mass_flow * second.humidity * (1 + first.humidity) ) / ( - first_specific_mass_flow - + first_specific_mass_flow * second.humidity - + second_specific_mass_flow - + second_specific_mass_flow * first.humidity + first_specific_mass_flow * (1 + second.humidity) + + second_specific_mass_flow * (1 + first.humidity) ) ), ) From 268fea1b8cd2046a518645b8b6668abdbe3ddac6 Mon Sep 17 00:00:00 2001 From: Vladimir Portyanikhin <86243191+portyanikhin@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:36:33 +0300 Subject: [PATCH 3/3] Fix `HumidAir.mixing` unit test --- tests/humid_air/test_humid_air_processes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/humid_air/test_humid_air_processes.py b/tests/humid_air/test_humid_air_processes.py index 2c5b961..10b37a0 100644 --- a/tests/humid_air/test_humid_air_processes.py +++ b/tests/humid_air/test_humid_air_processes.py @@ -392,5 +392,11 @@ def test_mixing(self): assert self.humid_air.mixing(1, first, 2, second) == self.humid_air.with_state( InputHumidAir.pressure(self.humid_air.pressure), InputHumidAir.enthalpy((1 * first.enthalpy + 2 * second.enthalpy) / 3), - InputHumidAir.humidity((1 * first.humidity + 2 * second.humidity) / 3), + InputHumidAir.humidity( + ( + 1 * first.humidity * (1 + second.humidity) + + 2 * second.humidity * (1 + first.humidity) + ) + / (1 * (1 + second.humidity) + 2 * (1 + first.humidity)) + ), )