From 040478e44bf3677e87c4c2ea37231516ca2923c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ja=C5=BCd=C5=BCyk?= Date: Wed, 9 Nov 2022 11:49:48 +0100 Subject: [PATCH] minor refactoring --- .../hvaclib/physics/PhysicsPropOfMoistAir.java | 13 +++++-------- .../hvaclib/physics/PhysicsPropOfWaterVapour.java | 5 ++--- .../hvaclib/process/ProcessOfHeatingCooling.java | 2 +- .../PhysicsPropOfMoistAirExceptionTest.java | 4 ++-- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfMoistAir.java b/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfMoistAir.java index 62bbf54..05f5e57 100644 --- a/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfMoistAir.java +++ b/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfMoistAir.java @@ -1,9 +1,6 @@ package io.github.pjazdzyk.hvaclib.physics; import io.github.pjazdzyk.brentsolver.BrentSolver; -import io.github.pjazdzyk.hvaclib.common.Limiters; -import io.github.pjazdzyk.hvaclib.common.UnitConverters; -import io.github.pjazdzyk.hvaclib.flows.FlowOfMoistAir; import io.github.pjazdzyk.hvaclib.physics.exceptions.AirPhysicsArgumentException; import java.util.function.DoubleFunction; @@ -59,8 +56,8 @@ private PhysicsPropOfMoistAir() { * @return temperature at provided altitude, oC */ public static double calcMaPs(double ta) { - if (ta < Limiters.MIN_T) - throw new AirPhysicsArgumentException("Minimum temperature exceeded tx=" + String.format("%.2foC", ta) + " t.min= " + Limiters.MIN_T); + if (ta < PhysicsLimiters.MIN_T) + throw new AirPhysicsArgumentException("Minimum temperature exceeded tx=" + String.format("%.2foC", ta) + " t.min= " + PhysicsLimiters.MIN_T); if (ta < -130) return 0.0; double exactPs; @@ -329,7 +326,7 @@ public static double calcMaK(double ta, double x, double dynVis_Da, double dynVi return k_Da; double sut_Da = PhysicsConstants.CST_DA_SUT; double sut_Wv = PhysicsConstants.CST_WV_SUT; - double tk = UnitConverters.convertCelsiusToKelvin(ta); + double tk = PhysicsUnitConverters.convertCelsiusToKelvin(ta); double sutAv = 0.733 * Math.sqrt(sut_Da * sut_Wv); double k_Wv = PhysicsPropOfWaterVapour.calcWvK(ta); double xm = 1.61 * x; @@ -364,8 +361,8 @@ public static double calcMaK(double ta, double x, double dynVis_Da, double dynVi public static double calcMaIx(double ta, double x, double Pat) { if (x < 0.0) throw new AirPhysicsArgumentException("Error. Value of x is smaller than 0." + String.format("x= %.3f", x)); - if (Pat < Limiters.MIN_PAT) - throw new AirPhysicsArgumentException("Error. Value of Pat is smaller than acceptable MIN value." + String.format("Pat= %.3f, minPat=%.3f", Pat, Limiters.MIN_PAT)); + if (Pat < PhysicsLimiters.MIN_PAT) + throw new AirPhysicsArgumentException("Error. Value of Pat is smaller than acceptable MIN value." + String.format("Pat= %.3f, minPat=%.3f", Pat, PhysicsLimiters.MIN_PAT)); double i_Da = PhysicsPropOfDryAir.calcDaI(ta); //Case1: no humidity = dry air only if (x == 0.0) diff --git a/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfWaterVapour.java b/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfWaterVapour.java index fb506c2..d3e52cd 100644 --- a/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfWaterVapour.java +++ b/src/main/java/io/github/pjazdzyk/hvaclib/physics/PhysicsPropOfWaterVapour.java @@ -1,6 +1,5 @@ package io.github.pjazdzyk.hvaclib.physics; -import io.github.pjazdzyk.hvaclib.common.UnitConverters; import io.github.pjazdzyk.hvaclib.physics.exceptions.AirPhysicsArgumentException; public final class PhysicsPropOfWaterVapour { @@ -59,7 +58,7 @@ public static double calcWvI(double ta) { * @return dry air specific heat, kJ/(kg*K) */ public static double calcWvCp(double ta) { - double tk = UnitConverters.convertCelsiusToKelvin(ta); + double tk = PhysicsUnitConverters.convertCelsiusToKelvin(ta); double c0, c1, c2, c3, c4, c5, c6; if (ta <= -48.15) { c0 = 1.8429999999889115e+000; @@ -90,7 +89,7 @@ public static double calcWvCp(double ta) { * @return water vapour density, kg/m3 */ public static double calcWvRho(double ta, double RH, double Pat) { - double tk = UnitConverters.convertCelsiusToKelvin(ta); + double tk = PhysicsUnitConverters.convertCelsiusToKelvin(ta); double P_Da = RH / 100 * PhysicsPropOfMoistAir.calcMaPs(ta); double P_Wv = Pat - P_Da; return P_Wv / (PhysicsConstants.CST_WV_RG * tk); diff --git a/src/main/java/io/github/pjazdzyk/hvaclib/process/ProcessOfHeatingCooling.java b/src/main/java/io/github/pjazdzyk/hvaclib/process/ProcessOfHeatingCooling.java index ceb6fca..7d3d3c5 100644 --- a/src/main/java/io/github/pjazdzyk/hvaclib/process/ProcessOfHeatingCooling.java +++ b/src/main/java/io/github/pjazdzyk/hvaclib/process/ProcessOfHeatingCooling.java @@ -7,7 +7,7 @@ import io.github.pjazdzyk.hvaclib.common.Defaults; import io.github.pjazdzyk.hvaclib.physics.PhysicsDefaults; import io.github.pjazdzyk.hvaclib.physics.PhysicsOfHeatingCooling; -import io.github.pjazdzyk.hvaclib.common.MathUtils; +import io.github.pjazdzyk.hvaclib.physics.MathUtils; import io.github.pjazdzyk.hvaclib.common.Validators; import io.github.pjazdzyk.hvaclib.fluids.Fluid; import io.github.pjazdzyk.hvaclib.fluids.MoistAir; diff --git a/src/test/java/io/github/pjazdzyk/hvaclib/process/exceptions/PhysicsPropOfMoistAirExceptionTest.java b/src/test/java/io/github/pjazdzyk/hvaclib/process/exceptions/PhysicsPropOfMoistAirExceptionTest.java index 4922931..9b1d974 100644 --- a/src/test/java/io/github/pjazdzyk/hvaclib/process/exceptions/PhysicsPropOfMoistAirExceptionTest.java +++ b/src/test/java/io/github/pjazdzyk/hvaclib/process/exceptions/PhysicsPropOfMoistAirExceptionTest.java @@ -1,6 +1,6 @@ package io.github.pjazdzyk.hvaclib.process.exceptions; -import io.github.pjazdzyk.hvaclib.common.Limiters; +import io.github.pjazdzyk.hvaclib.physics.PhysicsLimiters; import io.github.pjazdzyk.hvaclib.physics.PhysicsPropOfMoistAir; import io.github.pjazdzyk.hvaclib.physics.exceptions.AirPhysicsArgumentException; import org.junit.jupiter.api.DisplayName; @@ -16,7 +16,7 @@ class PhysicsPropOfMoistAirExceptionTest { @DisplayName("should throw an exception when temperature is lower than minimum limiter is given") void calcMaPs_shouldThrowException_whenTemperatureIsLowerThanMinimumLimitIsGiven() { // Arrange - var tempOutsideThreshold = Limiters.MIN_T - 1; + var tempOutsideThreshold = PhysicsLimiters.MIN_T - 1; // Assert assertThrows(AirPhysicsArgumentException.class, () -> PhysicsPropOfMoistAir.calcMaPs(tempOutsideThreshold));