Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pjazdzyk committed Nov 9, 2022
1 parent ada310e commit 040478e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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));
Expand Down

0 comments on commit 040478e

Please sign in to comment.