From e5aa80139857fc5ac39bf9a57b470a4f14fd5235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:18:17 +0100 Subject: [PATCH] feat: fix typo and package name (#834) * feat: fix typo and package name * test: added main function as test --- .../{DataSmoothor.java => DataSmoother.java} | 47 +++++++------------ .../WettedWallColumnSampleCreator.java | 45 +++++++++--------- .../datasmoothing/DataSmootherTest.java | 21 +++++++++ 3 files changed, 59 insertions(+), 54 deletions(-) rename src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/{DataSmoothor.java => DataSmoother.java} (78%) create mode 100644 src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java diff --git a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java b/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoother.java similarity index 78% rename from src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java rename to src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoother.java index 680086635e..613d500c02 100644 --- a/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoothor.java +++ b/src/main/java/neqsim/statistics/dataAnalysis/dataSmoothing/DataSmoother.java @@ -1,10 +1,10 @@ /* - * DataSmoothor.java + * DataSmoother.java * * Created on 31. januar 2001, 21:27 */ -package neqsim.statistics.dataAnalysis.dataSmoothing; +package neqsim.statistics.dataanalysis.datasmoothing; import Jama.Matrix; @@ -16,20 +16,22 @@ * @author Even Solbraa * @version $Id: $Id */ -public class DataSmoothor { - double[] nonSmoothedNumbers, smoothedNumbers, cCoef; - int nl = 0, nr = 0, ld = 0, m = 0, mm = 0, imj = 0, kk = 0; +public class DataSmoother { + double[] nonSmoothedNumbers; + double[] smoothedNumbers; + double[] cCoef; + int nl = 0; + int nr = 0; + int ld = 0; + int m = 0; + int mm = 0; + int imj = 0; + int kk = 0; int[] index; double[][] a; double[] b; - double sum = 0, fac = 0; - - /** - *

- * Constructor for DataSmoothor. - *

- */ - public DataSmoothor() {} + double sum = 0; + double fac = 0; /** *

@@ -42,7 +44,7 @@ public DataSmoothor() {} * @param ld a int * @param m a int */ - public DataSmoothor(double[] nonSmoothedNumbers, int nl, int nr, int ld, int m) { + public DataSmoother(double[] nonSmoothedNumbers, int nl, int nr, int ld, int m) { this.nonSmoothedNumbers = new double[nonSmoothedNumbers.length]; this.smoothedNumbers = new double[nonSmoothedNumbers.length]; this.cCoef = new double[nonSmoothedNumbers.length]; @@ -157,21 +159,4 @@ public void setSmoothedNumbers() { public double[] getSmoothedNumbers() { return smoothedNumbers; } - - /** - *

- * main. - *

- * - * @param args an array of {@link java.lang.String} objects - */ - public static void main(String args[]) { - double[] numbers = {10, 11, 12, 13, 14, 15, 15.5, 15, 19, 14, 14, 13, 12, 12, 11, 10, 9, 8}; - DataSmoothor test = new DataSmoothor(numbers, 3, 3, 0, 4); - Matrix data = new Matrix(test.getSmoothedNumbers(), 1); - data.print(10, 2); - test.runSmoothing(); - data = new Matrix(test.getSmoothedNumbers(), 1); - data.print(10, 2); - } } diff --git a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java index e05491b68f..8184637dad 100644 --- a/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java +++ b/src/main/java/neqsim/statistics/experimentalSampleCreation/sampleCreator/wettedWallColumnSampleCreator/WettedWallColumnSampleCreator.java @@ -7,7 +7,7 @@ package neqsim.statistics.experimentalSampleCreation.sampleCreator.wettedWallColumnSampleCreator; import Jama.Matrix; -import neqsim.statistics.dataAnalysis.dataSmoothing.DataSmoothor; +import neqsim.statistics.dataanalysis.datasmoothing.DataSmoother; import neqsim.statistics.experimentalEquipmentData.ExperimentalEquipmentData; import neqsim.statistics.experimentalEquipmentData.wettedWallColumnData.WettedWallColumnData; import neqsim.statistics.experimentalSampleCreation.readDataFromFile.wettedWallColumnReader.WettedWallColumnDataObject; @@ -26,7 +26,6 @@ */ public class WettedWallColumnSampleCreator extends SampleCreator { WettedWallDataReader reader; - DataSmoothor smoothor; double[] time; double[] pressure; double[] inletLiquidTemperature; @@ -115,33 +114,33 @@ public void smoothData() { Matrix data = new Matrix(pressure, 1); data.print(10, 2); - smoothor = new DataSmoothor(pressure, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedPressure = smoothor.getSmoothedNumbers(); + DataSmoother smoother = new DataSmoother(pressure, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedPressure = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletLiquidTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletLiquidTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletLiquidTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletLiquidTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(outletLiquidTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedOutletLiquidTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(outletLiquidTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedOutletLiquidTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(columnWallTemperature, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedColumnWallTemperature = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(columnWallTemperature, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedColumnWallTemperature = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletTotalGasFlowRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletTotalGasFlowRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletTotalGasFlowRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletTotalGasFlowRate = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(co2SupplyRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedCo2SupplyRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(co2SupplyRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedCo2SupplyRate = smoother.getSmoothedNumbers(); - smoothor = new DataSmoothor(inletLiquidFlowRate, 10, 10, 0, 2); - smoothor.runSmoothing(); - smoothedInletLiquidFlowRate = smoothor.getSmoothedNumbers(); + smoother = new DataSmoother(inletLiquidFlowRate, 10, 10, 0, 2); + smoother.runSmoothing(); + smoothedInletLiquidFlowRate = smoother.getSmoothedNumbers(); data = new Matrix(smoothedPressure, 1); data.print(10, 2); diff --git a/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java b/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java new file mode 100644 index 0000000000..681f6da47c --- /dev/null +++ b/src/test/java/neqsim/statistics/dataanalysis/datasmoothing/DataSmootherTest.java @@ -0,0 +1,21 @@ +package neqsim.statistics.dataanalysis.datasmoothing; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class DataSmootherTest { + + @Test + void testgetSmoothedNumbers() { + double[] numbers = {10, 11, 12, 13, 14, 15, 15.5, 15, 19, 14, 14, 13, 12, 12, 11, 10, 9, 8}; + DataSmoother test = new DataSmoother(numbers, 3, 3, 0, 4); + Assertions.assertArrayEquals(numbers, test.getSmoothedNumbers()); + + double[] expected = {10.000000, 11.000000, 12.000000, 12.567099567099579, 13.567099567099582, + 14.556277056277072, 15.305194805194823, 15.389610389610409, 16.66233766233768, + 17.149350649350666, 13.350649350649375, 13.627705627705646, 12.432900432900452, + 11.89177489177491, 11.541125541125552, 10.000000, 9.000000, 8.000000}; + test.runSmoothing(); + Assertions.assertArrayEquals(expected, test.getSmoothedNumbers()); + } +}