From 82383acb635b07aa42d5800858b040cf48cb7df0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 16 Jan 2020 09:20:24 -0500 Subject: [PATCH 001/217] Added blank header and implementation files for pump table and added Dockerfile --- CMakeLists.txt | 7 ++- Dockerfile | 96 ++++++++++++++++++++++++++++++ commands.txt | 28 +++++++++ include/calculator/pump/PumpData.h | 0 include/sqlite/PumpData.h | 0 src/calculator/pump/PumpData.cpp | 0 6 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 commands.txt create mode 100644 include/calculator/pump/PumpData.h create mode 100644 include/sqlite/PumpData.h create mode 100644 src/calculator/pump/PumpData.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fa50612..f0b671eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,7 +194,8 @@ set(SOURCE_FILES src/calculator/util/insulation/services/RayleighNumber.cpp src/calculator/util/insulation/services/ReynoldsNumber.cpp src/calculator/util/insulation/services/ThermalResistance.cpp - src/calculator/util/SteamReduction.cpp) + src/calculator/util/SteamReduction.cpp + src/calculator/pump/PumpData.cpp) set(INCLUDE_FILES include/results/Results.h @@ -372,8 +373,12 @@ set(INCLUDE_FILES include/fans/FanEnergyIndex.h include/fans/OptimalFanEfficiency.h include/ssmt/HeatExchanger.h + include/calculator/pump/PumpData.h + include/sqlite/PumpData.h ) +# TODO: Add unit test for Pump Table + set(TEST_FILES tests/OptimalSpecificSpeedCorrection.unit.cpp tests/MotorEfficiency.unit.cpp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ede0c955 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,96 @@ +FROM ubuntu:18.04 + +WORKDIR /home/ + +RUN apt -y update +RUN apt -y upgrade + +# Install gcc +RUN apt -y install build-essential +RUN apt-get -y install manpages-dev +RUN gcc --version + +# Install Python +RUN apt-get -y install python +RUN python --version + +# Install curl +RUN apt -y install curl + +# Install cmake +RUN apt -y install cmake +RUN cmake --version + +# Install ccmake +RUN apt -y install cmake-curses-gui +RUN ccmake --version + +# Install Doxygen +RUN apt -y install doxygen +RUN doxygen --version + +# Install nvm +#RUN touch ~/.bash_profile +#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +#RUN source ~/.nvm/nvm.sh +#RUN nvm --version + +# Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) +#RUN nvm install node +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +RUN apt-get install -y nodejs +RUN node --version +RUN npm --version + +# Install npm +#RUN apt -y install npm +#RUN npm --version + +# Install gyp +RUN npm install -g node-gyp@4.0.0 +RUN node-gyp -v + + +# Add AMO-Tools-Suite +RUN mkdir AMO +RUN mkdir AMO/AMO-Tools-Suite +# Inside AMO-Tools-Suite directory +ADD . /home/AMO/AMO-Tools-Suite/ + + +#RUN touch package.json +WORKDIR /home/AMO/AMO-Tools-Suite/ + +# Install Node Tap (test suite) +# @12.6.0, --save-dev +RUN npm install tap@12.6.0 --save-dev +#RUN apt -y install node-tap +#RUN tap --version + +WORKDIR /home/ + +# Install emacs +RUN apt-get -y install emacs +RUN emacs --version + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- +WORKDIR /home/AMO/AMO-Tools-Suite/ + +RUN cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ + +RUN cmake --build . + +RUN ./bin/amo_tools_suite_tests + +RUN npm install + +RUN node-gyp rebuild + +RUN npm run test + +RUN npm run at +#-------------------------------------------------------------- + +WORKDIR /home/ diff --git a/commands.txt b/commands.txt new file mode 100644 index 00000000..f72e74a6 --- /dev/null +++ b/commands.txt @@ -0,0 +1,28 @@ +docker image build -t comma64/ornl:issue-258 . +docker run -t -d --name amo comma64/ornl:issue-258 +docker exec -it amo /bin/bash +docker container rm --force amo + +docker login +docker push comma64/ornl:issue-258 + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- + +cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ +alternatively: ccmake . + +cmake --build . --target amo_tools_suite_tests +alternatively: cmake --build . + +./bin/amo_tools_suite_tests + +npm install (OR (if necessary): npm install --unsafe-perm) +alternatively (if already installed): node-gyp rebuild + +npm run test + +npm run at +#-------------------------------------------------------------- + diff --git a/include/calculator/pump/PumpData.h b/include/calculator/pump/PumpData.h new file mode 100644 index 00000000..e69de29b diff --git a/include/sqlite/PumpData.h b/include/sqlite/PumpData.h new file mode 100644 index 00000000..e69de29b diff --git a/src/calculator/pump/PumpData.cpp b/src/calculator/pump/PumpData.cpp new file mode 100644 index 00000000..e69de29b From ed379c90145204c24480c853898dfecd9ac6215e Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 21 Jan 2020 13:07:30 -0500 Subject: [PATCH 002/217] Updated Dockerfile and commands.txt --- Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++------ commands.txt | 6 +++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index ede0c955..590801e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,22 +29,67 @@ RUN ccmake --version RUN apt -y install doxygen RUN doxygen --version -# Install nvm +# -------------------------------------------------------------------------------------------- + +# Install nvm, node and npm #RUN touch ~/.bash_profile #RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash -#RUN source ~/.nvm/nvm.sh +# replace shell with bash so we can source files +#RUN rm /bin/sh && ln -s /bin/bash /bin/sh +#RUN source ~/.nvm/nvm.sh \ nvm --version +#RUN export NVM_DIR="$HOME/.nvm" +#RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +#RUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion #RUN nvm --version + + +# replace shell with bash so we can source files +RUN rm /bin/sh && ln -s /bin/bash /bin/sh + +# update the repository sources list +# and install dependencies +RUN apt-get update \ + && apt-get install -y curl \ + && apt-get -y autoclean + +# nvm environment variables +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 12.8.0 + +# install nvm +# https://github.com/creationix/nvm#install-script +RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash + +# install node and npm +RUN source $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +# add node and npm to path so the commands are available +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +# confirm installation +RUN node -v +RUN npm -v +# --------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------- +# This section is currently inactive + # Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) #RUN nvm install node -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - -RUN apt-get install -y nodejs -RUN node --version -RUN npm --version +#RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +#RUN apt-get install -y nodejs +#RUN node --version +#RUN npm --version # Install npm #RUN apt -y install npm #RUN npm --version +# --------------------------------------------------------------------------------------------- # Install gyp RUN npm install -g node-gyp@4.0.0 diff --git a/commands.txt b/commands.txt index f72e74a6..adc3e13a 100644 --- a/commands.txt +++ b/commands.txt @@ -1,7 +1,7 @@ docker image build -t comma64/ornl:issue-258 . -docker run -t -d --name amo comma64/ornl:issue-258 -docker exec -it amo /bin/bash -docker container rm --force amo +docker run -t -d --name amo-suite comma64/ornl:issue-258 +docker exec -it amo-suite /bin/bash +docker container rm --force amo-suite docker login docker push comma64/ornl:issue-258 From 9419f6921ea16b13859ca5f6c0e5dbe5088b5b9d Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Jan 2020 13:02:38 -0500 Subject: [PATCH 003/217] Added header and implementation files for Pump Table --- include/calculator/pump/PumpData.h | 238 +++++++++++++++++ include/sqlite/PumpData.h | 18 ++ include/sqlite/SQLite.h | 3 + src/calculator/pump/PumpData.cpp | 414 +++++++++++++++++++++++++++++ src/sqlite/SQLite.cpp | 2 + 5 files changed, 675 insertions(+) diff --git a/include/calculator/pump/PumpData.h b/include/calculator/pump/PumpData.h index e69de29b..1905a060 100644 --- a/include/calculator/pump/PumpData.h +++ b/include/calculator/pump/PumpData.h @@ -0,0 +1,238 @@ +// +// Created by zf9 on 7/16/18. +// Re-implemented by causeyc on 1/27/2020 + +#ifndef AMO_TOOLS_SUITE_PUMPDATA_H +#define AMO_TOOLS_SUITE_PUMPDATA_H + +#include + +class PumpData { +public: + PumpData(std::string manufacturer, std::string model, std::string type, std::string serialNumber, + std::string status, std::string pumpType, std::string radialBearingType, std::string thrustBearingType, + std::string shaftOrientation, std::string shaftSealType, std::string fluidType, std::string priority, + std::string driveType, std::string flangeConnectionClass, std::string flangeConnectionSize, + int numShafts, int speed, int numStages, int yearlyOperatingHours, int yearInstalled, int finalMotorRpm, + double inletDiameter, double weight, double outletDiameter, double percentageOfSchedule, + double dailyPumpCapacity, double measuredPumpCapacity, double pumpPerformance, double staticSuctionHead, + double staticDischargeHead, double fluidDensity, double lengthOfDischargePipe, + double pipeDesignFrictionLosses, double maxWorkingPressure, double maxAmbientTemperature, + double maxSuctionLift, double displacement, double startingTorque, double ratedSpeed, + double shaftDiameter, double impellerDiameter, double efficiency, double output60Hz, double minFlowSize, + double pumpSize, bool outOfService); + + const bool &getOutOfService() const; + + void setOutOfService(const bool &outOfService); + + const double &getInletDiameter() const; + + void setInletDiameter(const double &inletDiameter); + + const double &getOutletDiameter() const; + + void setOutletDiameter(const double &outletDiameter); + + const double &getPercentageOfSchedule() const; + + void setPercentageOfSchedule(const double &percentageOfSchedule); + + const double &getDailyPumpCapacity() const; + + void setDailyPumpCapacity(const double &dailyPumpCapacity); + + const double &getMeasuredPumpCapacity() const; + + void setMeasuredPumpCapacity(const double &measuredPumpCapacity); + + const double &getPumpPerformance() const; + + void setPumpPerformance(const double &pumpPerformance); + + const double &getStaticSuctionHead() const; + + void setStaticSuctionHead(const double &staticSuctionHead); + + const double &getStaticDischargeHead() const; + + void setStaticDischargeHead(const double &staticDischargeHead); + + const double &getFluidDensity() const; + + void setFluidDensity(const double &fluidDensity); + + const double &getLengthOfDischargePipe() const; + + void setLengthOfDischargePipe(const double &lengthOfDischargePipe); + + const double &getPipeDesignFrictionLosses() const; + + void setPipeDesignFrictionLosses(const double &pipeDesignFrictionLosses); + + const double &getMaxWorkingPressure() const; + + void setMaxWorkingPressure(const double &maxWorkingPressure); + + const double &getMaxAmbientTemperature() const; + + void setMaxAmbientTemperature(const double &maxAmbientTemperature); + + const double &getMaxSuctionLift() const; + + void setMaxSuctionLift(const double &maxSuctionLift); + + const double &getDisplacement() const; + + void setDisplacement(const double &displacement); + + const double &getStartingTorque() const; + + void setStartingTorque(const double &startingTorque); + + const double &getRatedSpeed() const; + + void setRatedSpeed(const double &ratedSpeed); + + const double &getMinFlowSize() const; + + void setMinFlowSize(const double &minFlowSize); + + const double &getPumpSize() const; + + void setPumpSize(const double &pumpSize); + + const double &getShaftDiameter() const; + + void setShaftDiameter(const double &shaftDiameter); + + const double &getImpellerDiameter() const; + + void setImpellerDiameter(const double &impellerDiameter); + + const double &getEfficiency() const; + + void setEfficiency(const double &efficiency); + + const double &getOutput60Hz() const; + + void setOutput60Hz(const double &output60Hz); + + const int &getSpeed() const; + + void setSpeed(const int &speed); + + const int &getNumShafts() const; + + void setNumShafts(const int &numShafts); + + const int &getNumStages() const; + + void setNumStages(const int &numStages); + + const int &getYearlyOperatingHours() const; + + void setYearlyOperatingHours(const int &yearlyOperatingHours); + + const int &getYearInstalled() const; + + void setYearInstalled(const int &yearInstalled); + + const std::string &getSerialNumber() const; + + void setSerialNumber(const std::string &serialNumber); + + const std::string &getStatus() const; + + void setStatus(const std::string &status); + + const std::string &getPumpType() const; + + void setPumpType(const std::string &pumpType); + + const std::string &getRadialBearingType() const; + + void setRadialBearingType(const std::string &radialBearingType); + + const std::string &getThrustBearingType() const; + + void setThrustBearingType(const std::string &thrustBearingType); + + const std::string &getShaftOrientation() const; + + void setShaftOrientation(const std::string &shaftOrientation); + + const std::string &getShaftSealType() const; + + void setShaftSealType(const std::string &shaftSealType); + + const std::string &getFluidType() const; + + void setFluidType(const std::string &fluidType); + + const std::string &getDriveType() const; + + void setDriveType(const std::string &driveType); + + const std::string &getFlangeConnectionClass() const; + + void setFlangeConnectionClass(const std::string &flangeConnectionClass); + + const std::string &getFlangeConnectionSize() const; + + void setFlangeConnectionSize(const std::string &flangeConnectionSize); + + const std::string &getType() const; + + void setType(const std::string &type); + + const std::string &getManufacturer() const; + + void setManufacturer(const std::string &manufacturer); + + const std::string &getModel() const; + + void setModel(const std::string &model); + + const std::string &getPriority() const; + + void setPriority(const std::string &priority); + + int getFinalMotorRpm() const; + + void setFinalMotorRpm(int finalMotorRpm); + + double getWeight() const; + + void setWeight(double weight); + + bool isOutOfService() const; + + int getId() const; + + void setId(int id); + + +private: + std::string manufacturer, model, serialNumber, type, status, pumpType, radialBearingType, thrustBearingType; + std::string shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass; + std::string flangeConnectionSize; + + int numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, finalMotorRpm; + + double inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance; + double staticSuctionHead, staticDischargeHead, fluidDensity, lengthOfDischargePipe, + pipeDesignFrictionLosses, maxWorkingPressure; + double maxAmbientTemperature, maxSuctionLift, displacement, startingTorque, ratedSpeed, + shaftDiameter, impellerDiameter; + double efficiency, output60Hz, minFlowSize, pumpSize; + + bool outOfService; + + int id; // used for the database + + friend class SQLite; +}; + +#endif //AMO_TOOLS_SUITE_PUMPDATA_H \ No newline at end of file diff --git a/include/sqlite/PumpData.h b/include/sqlite/PumpData.h index e69de29b..fcad711b 100644 --- a/include/sqlite/PumpData.h +++ b/include/sqlite/PumpData.h @@ -0,0 +1,18 @@ +#ifndef AMO_TOOLS_SUITE_PUMPDATADB_H +#define AMO_TOOLS_SUITE_PUMPDATADB_H + +class PumpData; + +std::vector SQLite::get_default_pump_data() { + return { + { + "manufacturer", "model", "type", "serialNumber", "status", "pumpType", "radialBearingType", + "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", + "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 + } + }; +} + + +#endif //AMO_TOOLS_SUITE_PUMPDATADB_H \ No newline at end of file diff --git a/include/sqlite/SQLite.h b/include/sqlite/SQLite.h index 3c465fb2..90b71b25 100644 --- a/include/sqlite/SQLite.h +++ b/include/sqlite/SQLite.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include class SolidLoadChargeMaterial; class LiquidLoadChargeMaterial; @@ -16,6 +18,7 @@ class SolidLiquidFlueGasMaterial; class Atmosphere; class WallLosses; class MotorData; +class PumpData; class SQLiteWrapper { diff --git a/src/calculator/pump/PumpData.cpp b/src/calculator/pump/PumpData.cpp index e69de29b..fb168342 100644 --- a/src/calculator/pump/PumpData.cpp +++ b/src/calculator/pump/PumpData.cpp @@ -0,0 +1,414 @@ +// +// Created by zf9 on 7/16/18. +// Re-implemented by causeyc on 1/27/2020 + +#include "calculator/pump/PumpData.h" + +PumpData::PumpData(std::string manufacturer, std::string model, std::string type, std::string serialNumber, + std::string status, std::string pumpType, std::string radialBearingType, std::string thrustBearingType, + std::string shaftOrientation, std::string shaftSealType, std::string fluidType, std::string priority, + std::string driveType, std::string flangeConnectionClass, std::string flangeConnectionSize, + int numShafts, int speed, int numStages, int yearlyOperatingHours, int yearInstalled, + int finalMotorRpm, double inletDiameter, double weight, double outletDiameter, + double percentageOfSchedule, double dailyPumpCapacity, double measuredPumpCapacity, + double pumpPerformance, double staticSuctionHead, double staticDischargeHead, double fluidDensity, + double lengthOfDischargePipe, double pipeDesignFrictionLosses, double maxWorkingPressure, + double maxAmbientTemperature, double maxSuctionLift, double displacement, double startingTorque, + double ratedSpeed, double shaftDiameter, double impellerDiameter, double efficiency, + double output60Hz, double minFlowSize, double pumpSize, bool outOfService) + : manufacturer(std::move(manufacturer)), model(std::move(model)), type(std::move(type)), serialNumber(std::move(serialNumber)), + status(std::move(status)), pumpType(std::move(pumpType)), radialBearingType(std::move(radialBearingType)), + thrustBearingType(std::move(thrustBearingType)), shaftOrientation(std::move(shaftOrientation)), shaftSealType(std::move(shaftSealType)), + fluidType(std::move(fluidType)), priority(std::move(priority)), driveType(std::move(driveType)), flangeConnectionClass(std::move(flangeConnectionClass)), + flangeConnectionSize(std::move(flangeConnectionSize)), numShafts(numShafts), speed(speed), numStages(numStages), + yearlyOperatingHours(yearlyOperatingHours), yearInstalled(yearInstalled), finalMotorRpm(finalMotorRpm), + inletDiameter(inletDiameter), weight(weight), outletDiameter(outletDiameter), percentageOfSchedule(percentageOfSchedule), dailyPumpCapacity(dailyPumpCapacity), + measuredPumpCapacity(measuredPumpCapacity), pumpPerformance(pumpPerformance), staticSuctionHead(staticSuctionHead), + staticDischargeHead(staticDischargeHead), fluidDensity(fluidDensity), lengthOfDischargePipe(lengthOfDischargePipe), + pipeDesignFrictionLosses(pipeDesignFrictionLosses), maxWorkingPressure(maxWorkingPressure), + maxAmbientTemperature(maxAmbientTemperature), maxSuctionLift(maxSuctionLift), displacement(displacement), + startingTorque(startingTorque), ratedSpeed(ratedSpeed), shaftDiameter(shaftDiameter), impellerDiameter(impellerDiameter), + efficiency(efficiency), output60Hz(output60Hz), minFlowSize(minFlowSize), pumpSize(pumpSize), outOfService(outOfService) +{} + + +const bool &PumpData::getOutOfService() const { + return outOfService; +} + +void PumpData::setOutOfService(const bool &outOfService) { + PumpData::outOfService = outOfService; +} + +const double &PumpData::getInletDiameter() const { + return inletDiameter; +} + +void PumpData::setInletDiameter(const double &inletDiameter) { + PumpData::inletDiameter = inletDiameter; +} + +const double &PumpData::getOutletDiameter() const { + return outletDiameter; +} + +void PumpData::setOutletDiameter(const double &outletDiameter) { + PumpData::outletDiameter = outletDiameter; +} + +const double &PumpData::getPercentageOfSchedule() const { + return percentageOfSchedule; +} + +void PumpData::setPercentageOfSchedule(const double &percentageOfSchedule) { + PumpData::percentageOfSchedule = percentageOfSchedule; +} + +const double &PumpData::getDailyPumpCapacity() const { + return dailyPumpCapacity; +} + +void PumpData::setDailyPumpCapacity(const double &dailyPumpCapacity) { + PumpData::dailyPumpCapacity = dailyPumpCapacity; +} + +const double &PumpData::getMeasuredPumpCapacity() const { + return measuredPumpCapacity; +} + +void PumpData::setMeasuredPumpCapacity(const double &measuredPumpCapacity) { + PumpData::measuredPumpCapacity = measuredPumpCapacity; +} + +const double &PumpData::getPumpPerformance() const { + return pumpPerformance; +} + +void PumpData::setPumpPerformance(const double &pumpPerformance) { + PumpData::pumpPerformance = pumpPerformance; +} + +const double &PumpData::getStaticSuctionHead() const { + return staticSuctionHead; +} + +void PumpData::setStaticSuctionHead(const double &staticSuctionHead) { + PumpData::staticSuctionHead = staticSuctionHead; +} + +const double &PumpData::getStaticDischargeHead() const { + return staticDischargeHead; +} + +void PumpData::setStaticDischargeHead(const double &staticDischargeHead) { + PumpData::staticDischargeHead = staticDischargeHead; +} + +const double &PumpData::getFluidDensity() const { + return fluidDensity; +} + +void PumpData::setFluidDensity(const double &fluidDensity) { + PumpData::fluidDensity = fluidDensity; +} + +const double &PumpData::getLengthOfDischargePipe() const { + return lengthOfDischargePipe; +} + +void PumpData::setLengthOfDischargePipe(const double &lengthOfDischargePipe) { + PumpData::lengthOfDischargePipe = lengthOfDischargePipe; +} + +const double &PumpData::getPipeDesignFrictionLosses() const { + return pipeDesignFrictionLosses; +} + +void PumpData::setPipeDesignFrictionLosses(const double &pipeDesignFrictionLosses) { + PumpData::pipeDesignFrictionLosses = pipeDesignFrictionLosses; +} + +const double &PumpData::getMaxWorkingPressure() const { + return maxWorkingPressure; +} + +void PumpData::setMaxWorkingPressure(const double &maxWorkingPressure) { + PumpData::maxWorkingPressure = maxWorkingPressure; +} + +const double &PumpData::getMaxAmbientTemperature() const { + return maxAmbientTemperature; +} + +void PumpData::setMaxAmbientTemperature(const double &maxAmbientTemperature) { + PumpData::maxAmbientTemperature = maxAmbientTemperature; +} + +const double &PumpData::getMaxSuctionLift() const { + return maxSuctionLift; +} + +void PumpData::setMaxSuctionLift(const double &maxSuctionLift) { + PumpData::maxSuctionLift = maxSuctionLift; +} + +const double &PumpData::getDisplacement() const { + return displacement; +} + +void PumpData::setDisplacement(const double &displacement) { + PumpData::displacement = displacement; +} + +const double &PumpData::getStartingTorque() const { + return startingTorque; +} + +void PumpData::setStartingTorque(const double &startingTorque) { + PumpData::startingTorque = startingTorque; +} + +const double &PumpData::getRatedSpeed() const { + return ratedSpeed; +} + +void PumpData::setRatedSpeed(const double &ratedSpeed) { + PumpData::ratedSpeed = ratedSpeed; +} + +const double &PumpData::getMinFlowSize() const { + return minFlowSize; +} + +void PumpData::setMinFlowSize(const double &minFlowSize) { + PumpData::minFlowSize = minFlowSize; +} + +const double &PumpData::getPumpSize() const { + return pumpSize; +} + +void PumpData::setPumpSize(const double &pumpSize) { + PumpData::pumpSize = pumpSize; +} + +const double &PumpData::getShaftDiameter() const { + return shaftDiameter; +} + +void PumpData::setShaftDiameter(const double &shaftDiameter) { + PumpData::shaftDiameter = shaftDiameter; +} + +const double &PumpData::getImpellerDiameter() const { + return impellerDiameter; +} + +void PumpData::setImpellerDiameter(const double &impellerDiameter) { + PumpData::impellerDiameter = impellerDiameter; +} + +const double &PumpData::getEfficiency() const { + return efficiency; +} + +void PumpData::setEfficiency(const double &efficiency) { + PumpData::efficiency = efficiency; +} + +const double &PumpData::getOutput60Hz() const { + return output60Hz; +} + +void PumpData::setOutput60Hz(const double &output60Hz) { + PumpData::output60Hz = output60Hz; +} + +const int &PumpData::getSpeed() const { + return speed; +} + +void PumpData::setSpeed(const int &speed) { + PumpData::speed = speed; +} + +const int &PumpData::getNumShafts() const { + return numShafts; +} + +void PumpData::setNumShafts(const int &numShafts) { + PumpData::numShafts = numShafts; +} + +const int &PumpData::getNumStages() const { + return numStages; +} + +void PumpData::setNumStages(const int &numStages) { + PumpData::numStages = numStages; +} + +const int &PumpData::getYearlyOperatingHours() const { + return yearlyOperatingHours; +} + +void PumpData::setYearlyOperatingHours(const int &yearlyOperatingHours) { + PumpData::yearlyOperatingHours = yearlyOperatingHours; +} + +const int &PumpData::getYearInstalled() const { + return yearInstalled; +} + +void PumpData::setYearInstalled(const int &yearInstalled) { + PumpData::yearInstalled = yearInstalled; +} + +const std::string &PumpData::getSerialNumber() const { + return serialNumber; +} + +void PumpData::setSerialNumber(const std::string &serialNumber) { + PumpData::serialNumber = serialNumber; +} + +const std::string &PumpData::getStatus() const { + return status; +} + +void PumpData::setStatus(const std::string &status) { + PumpData::status = status; +} + +const std::string &PumpData::getPumpType() const { + return pumpType; +} + +void PumpData::setPumpType(const std::string &pumpType) { + PumpData::pumpType = pumpType; +} + +const std::string &PumpData::getRadialBearingType() const { + return radialBearingType; +} + +void PumpData::setRadialBearingType(const std::string &radialBearingType) { + PumpData::radialBearingType = radialBearingType; +} + +const std::string &PumpData::getThrustBearingType() const { + return thrustBearingType; +} + +void PumpData::setThrustBearingType(const std::string &thrustBearingType) { + PumpData::thrustBearingType = thrustBearingType; +} + +const std::string &PumpData::getShaftOrientation() const { + return shaftOrientation; +} + +void PumpData::setShaftOrientation(const std::string &shaftOrientation) { + PumpData::shaftOrientation = shaftOrientation; +} + +const std::string &PumpData::getShaftSealType() const { + return shaftSealType; +} + +void PumpData::setShaftSealType(const std::string &shaftSealType) { + PumpData::shaftSealType = shaftSealType; +} + +const std::string &PumpData::getFluidType() const { + return fluidType; +} + +void PumpData::setFluidType(const std::string &fluidType) { + PumpData::fluidType = fluidType; +} + +const std::string &PumpData::getDriveType() const { + return driveType; +} + +void PumpData::setDriveType(const std::string &driveType) { + PumpData::driveType = driveType; +} + +const std::string &PumpData::getFlangeConnectionClass() const { + return flangeConnectionClass; +} + +void PumpData::setFlangeConnectionClass(const std::string &flangeConnectionClass) { + PumpData::flangeConnectionClass = flangeConnectionClass; +} + +const std::string &PumpData::getFlangeConnectionSize() const { + return flangeConnectionSize; +} + +void PumpData::setFlangeConnectionSize(const std::string &flangeConnectionSize) { + PumpData::flangeConnectionSize = flangeConnectionSize; +} + +const std::string &PumpData::getType() const { + return type; +} + +void PumpData::setType(const std::string &type) { + PumpData::type = type; +} + +const std::string &PumpData::getManufacturer() const { + return manufacturer; +} + +void PumpData::setManufacturer(const std::string &manufacturer) { + PumpData::manufacturer = manufacturer; +} + +const std::string &PumpData::getModel() const { + return model; +} + +void PumpData::setModel(const std::string &model) { + PumpData::model = model; +} + +const std::string &PumpData::getPriority() const { + return priority; +} + +void PumpData::setPriority(const std::string &priority) { + PumpData::priority = priority; +} + +int PumpData::getFinalMotorRpm() const { + return finalMotorRpm; +} + +void PumpData::setFinalMotorRpm(int finalMotorRpm) { + PumpData::finalMotorRpm = finalMotorRpm; +} + +double PumpData::getWeight() const { + return weight; +} + +void PumpData::setWeight(double weight) { + PumpData::weight = weight; +} + +bool PumpData::isOutOfService() const { + return outOfService; +} + +int PumpData::getId() const { + return id; +} + +void PumpData::setId(int id) { + PumpData::id = id; +} + diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 9ee3b501..f13bc70a 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -17,6 +17,8 @@ #include #include #include +//#include +//#include SQLite::SQLite(std::string const & db_name, bool init_db) : From b41ae2b69370dac9a8fde45bbe746e54a8897d9c Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Jan 2020 13:10:40 -0500 Subject: [PATCH 004/217] Added header declaration to SQLite.cpp for calculator/motor/MotorData.h --- src/sqlite/SQLite.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index f13bc70a..a28a475d 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include From 6f0ac0a1e1ee757626caab7539c1d1e5b59feb09 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Jan 2020 13:54:58 -0500 Subject: [PATCH 005/217] SQLite.h --- include/sqlite/SQLite.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/sqlite/SQLite.h b/include/sqlite/SQLite.h index 90b71b25..7f9f2487 100644 --- a/include/sqlite/SQLite.h +++ b/include/sqlite/SQLite.h @@ -159,6 +159,13 @@ class SQLite : SQLiteWrapper bool deleteMotorData(int id); bool updateMotorData(MotorData const & motor); + std::vector getPumpData() const; + std::vector getCustomPumpData() const; + PumpData getPumpDataById(int id) const; + bool insertPumpData(PumpData const & pump); + bool deletePumpData(int id); + bool updatePumpData(PumpData const & pump); + private: // returns true if the material id falls in the default material id range inline bool isDefaultMaterial(const int id, std::size_t const defaultMaterialsSize) { @@ -221,6 +228,13 @@ class SQLite : SQLiteWrapper sqlite3_stmt * m_motor_data_update_stmt = nullptr; sqlite3_stmt * m_motor_data_delete_stmt = nullptr; + sqlite3_stmt * m_pump_data_insert_stmt = nullptr; + sqlite3_stmt * m_pump_data_select_stmt = nullptr; + sqlite3_stmt * m_pump_data_select_single_stmt = nullptr; + sqlite3_stmt * m_pump_data_select_custom_stmt = nullptr; + sqlite3_stmt * m_pump_data_update_stmt = nullptr; + sqlite3_stmt * m_pump_data_delete_stmt = nullptr; + void create_select_stmt(); void create_update_and_delete_stmt(); @@ -245,6 +259,8 @@ class SQLite : SQLiteWrapper bool insert_motor_data(MotorData const & m); + bool insert_pump_data(PumpData const & pump); + void insert_default_data(); std::vector get_default_solid_load_charge_materials(); @@ -262,6 +278,8 @@ class SQLite : SQLiteWrapper std::vector get_default_wall_losses_surface(); std::vector get_default_motor_data(); + + std::vector get_default_pump_data(); }; From 7b75cac3d640e55890c962841a3d2baa3e5582ea Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Jan 2020 14:07:24 -0500 Subject: [PATCH 006/217] Updated SQLite.cpp --- src/sqlite/SQLite.cpp | 207 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 206 insertions(+), 1 deletion(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index a28a475d..99b35e34 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -19,7 +19,7 @@ #include #include //#include -//#include +#include SQLite::SQLite(std::string const & db_name, bool init_db) : @@ -94,6 +94,15 @@ SQLite::~SQLite() sqlite3_finalize(m_wall_losses_surface_select_custom_stmt); sqlite3_finalize(m_wall_losses_surface_update_stmt); sqlite3_finalize(m_wall_losses_surface_delete_stmt); + + // TODO: Add motor here + + sqlite3_finalize(m_pump_data_insert_stmt); + sqlite3_finalize(m_pump_data_select_stmt); + sqlite3_finalize(m_pump_data_select_single_stmt); + sqlite3_finalize(m_pump_data_select_custom_stmt); + sqlite3_finalize(m_pump_data_update_stmt); + sqlite3_finalize(m_pump_data_delete_stmt); } std::string SQLiteWrapper::convert_text( const unsigned char * text ) { @@ -473,6 +482,202 @@ WallLosses SQLite::getWallLossesSurfaceById(int id) const return get_object(m_wall_losses_surface_select_single_stmt, id, cb); } +std::vector SQLite::getPumpData() const { + auto cb = [] (sqlite3_stmt * stmt) { + auto const id = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); // sid (secondary id denoting custom) + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const type = convert_text(sqlite3_column_text(stmt, 4)); + auto const serialNumber = convert_text(sqlite3_column_text(stmt, 5)); + auto const status = convert_text(sqlite3_column_text(stmt, 6)); + auto const pumpType = convert_text(sqlite3_column_text(stmt, 7)); + auto const radialBearingType = convert_text(sqlite3_column_text(stmt, 8)); + auto const thrustBearingType = convert_text(sqlite3_column_text(stmt, 9)); + auto const shaftOrientation = convert_text(sqlite3_column_text(stmt, 10)); + auto const shaftSealType = convert_text(sqlite3_column_text(stmt, 11)); + auto const fluidType = convert_text(sqlite3_column_text(stmt, 12)); + auto const priority = convert_text(sqlite3_column_text(stmt, 13)); + auto const driveType = convert_text(sqlite3_column_text(stmt, 14)); + auto const flangeConnectionClass = convert_text(sqlite3_column_text(stmt, 15)); + auto const flangeConnectionSize = convert_text(sqlite3_column_text(stmt, 16)); + auto const numShafts = sqlite3_column_int(stmt, 17); + auto const speed = sqlite3_column_int(stmt, 18); + auto const numStages = sqlite3_column_int(stmt, 19); + auto const yearlyOperatingHours = sqlite3_column_int(stmt, 20); + auto const yearInstalled = sqlite3_column_int(stmt, 21); + auto const finalMotorRpm = sqlite3_column_int(stmt, 22); + auto const inletDiameter = sqlite3_column_double(stmt, 23); + auto const weight = sqlite3_column_double(stmt, 24); + auto const outletDiameter = sqlite3_column_double(stmt, 25); + auto const percentageOfSchedule = sqlite3_column_double(stmt, 26); + auto const dailyPumpCapacity = sqlite3_column_double(stmt, 27); + auto const measuredPumpCapacity = sqlite3_column_double(stmt, 28); + auto const pumpPerformance = sqlite3_column_double(stmt, 29); + auto const staticSuctionHead = sqlite3_column_double(stmt, 30); + auto const staticDischargeHead = sqlite3_column_double(stmt, 31); + auto const fluidDensity = sqlite3_column_double(stmt, 32); + auto const lengthOfDischargePipe = sqlite3_column_double(stmt, 33); + auto const pipeDesignFrictionLosses = sqlite3_column_double(stmt, 34); + auto const maxWorkingPressure = sqlite3_column_double(stmt, 35); + auto const maxAmbientTemperature = sqlite3_column_double(stmt, 36); + auto const maxSuctionLift = sqlite3_column_double(stmt, 37); + auto const displacement = sqlite3_column_double(stmt, 38); + auto const startingTorque = sqlite3_column_double(stmt, 39); + auto const ratedSpeed = sqlite3_column_double(stmt, 40); + auto const shaftDiameter = sqlite3_column_double(stmt, 41); + auto const impellerDiameter = sqlite3_column_double(stmt, 42); + auto const efficiency = sqlite3_column_double(stmt, 43); + auto const output60Hz = sqlite3_column_double(stmt, 44); + auto const minFlowSize = sqlite3_column_double(stmt, 45); + auto const pumpSize = sqlite3_column_double(stmt, 46); + auto const outOfService = static_cast(sqlite3_column_int(stmt, 47)); + + auto pump = PumpData(manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService); + pump.setId(id); + return pump; + }; + return get_all_objects(m_pump_data_select_stmt, cb); +} + +std::vector SQLite::getCustomPumpData() const { + auto cb = [] (sqlite3_stmt * stmt) { + auto const id = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); // sid (secondary id denoting custom) + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const type = convert_text(sqlite3_column_text(stmt, 4)); + auto const serialNumber = convert_text(sqlite3_column_text(stmt, 5)); + auto const status = convert_text(sqlite3_column_text(stmt, 6)); + auto const pumpType = convert_text(sqlite3_column_text(stmt, 7)); + auto const radialBearingType = convert_text(sqlite3_column_text(stmt, 8)); + auto const thrustBearingType = convert_text(sqlite3_column_text(stmt, 9)); + auto const shaftOrientation = convert_text(sqlite3_column_text(stmt, 10)); + auto const shaftSealType = convert_text(sqlite3_column_text(stmt, 11)); + auto const fluidType = convert_text(sqlite3_column_text(stmt, 12)); + auto const priority = convert_text(sqlite3_column_text(stmt, 13)); + auto const driveType = convert_text(sqlite3_column_text(stmt, 14)); + auto const flangeConnectionClass = convert_text(sqlite3_column_text(stmt, 15)); + auto const flangeConnectionSize = convert_text(sqlite3_column_text(stmt, 16)); + auto const numShafts = sqlite3_column_int(stmt, 17); + auto const speed = sqlite3_column_int(stmt, 18); + auto const numStages = sqlite3_column_int(stmt, 19); + auto const yearlyOperatingHours = sqlite3_column_int(stmt, 20); + auto const yearInstalled = sqlite3_column_int(stmt, 21); + auto const finalMotorRpm = sqlite3_column_int(stmt, 22); + auto const inletDiameter = sqlite3_column_double(stmt, 23); + auto const weight = sqlite3_column_double(stmt, 24); + auto const outletDiameter = sqlite3_column_double(stmt, 25); + auto const percentageOfSchedule = sqlite3_column_double(stmt, 26); + auto const dailyPumpCapacity = sqlite3_column_double(stmt, 27); + auto const measuredPumpCapacity = sqlite3_column_double(stmt, 28); + auto const pumpPerformance = sqlite3_column_double(stmt, 29); + auto const staticSuctionHead = sqlite3_column_double(stmt, 30); + auto const staticDischargeHead = sqlite3_column_double(stmt, 31); + auto const fluidDensity = sqlite3_column_double(stmt, 32); + auto const lengthOfDischargePipe = sqlite3_column_double(stmt, 33); + auto const pipeDesignFrictionLosses = sqlite3_column_double(stmt, 34); + auto const maxWorkingPressure = sqlite3_column_double(stmt, 35); + auto const maxAmbientTemperature = sqlite3_column_double(stmt, 36); + auto const maxSuctionLift = sqlite3_column_double(stmt, 37); + auto const displacement = sqlite3_column_double(stmt, 38); + auto const startingTorque = sqlite3_column_double(stmt, 39); + auto const ratedSpeed = sqlite3_column_double(stmt, 40); + auto const shaftDiameter = sqlite3_column_double(stmt, 41); + auto const impellerDiameter = sqlite3_column_double(stmt, 42); + auto const efficiency = sqlite3_column_double(stmt, 43); + auto const output60Hz = sqlite3_column_double(stmt, 44); + auto const minFlowSize = sqlite3_column_double(stmt, 45); + auto const pumpSize = sqlite3_column_double(stmt, 46); + auto const outOfService = static_cast(sqlite3_column_int(stmt, 47)); + + auto pump = PumpData(manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService); + pump.setId(id); + return pump; + }; + return get_all_objects(m_pump_data_select_custom_stmt, cb); +} + +PumpData SQLite::getPumpDataById(int id) const { + auto cb = [] (sqlite3_stmt * stmt) { + + auto const dbId = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); // sid (secondary id denoting custom) + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const type = convert_text(sqlite3_column_text(stmt, 4)); + auto const serialNumber = convert_text(sqlite3_column_text(stmt, 5)); + auto const status = convert_text(sqlite3_column_text(stmt, 6)); + auto const pumpType = convert_text(sqlite3_column_text(stmt, 7)); + auto const radialBearingType = convert_text(sqlite3_column_text(stmt, 8)); + auto const thrustBearingType = convert_text(sqlite3_column_text(stmt, 9)); + auto const shaftOrientation = convert_text(sqlite3_column_text(stmt, 10)); + auto const shaftSealType = convert_text(sqlite3_column_text(stmt, 11)); + auto const fluidType = convert_text(sqlite3_column_text(stmt, 12)); + auto const priority = convert_text(sqlite3_column_text(stmt, 13)); + auto const driveType = convert_text(sqlite3_column_text(stmt, 14)); + auto const flangeConnectionClass = convert_text(sqlite3_column_text(stmt, 15)); + auto const flangeConnectionSize = convert_text(sqlite3_column_text(stmt, 16)); + auto const numShafts = sqlite3_column_int(stmt, 17); + auto const speed = sqlite3_column_int(stmt, 18); + auto const numStages = sqlite3_column_int(stmt, 19); + auto const yearlyOperatingHours = sqlite3_column_int(stmt, 20); + auto const yearInstalled = sqlite3_column_int(stmt, 21); + auto const finalMotorRpm = sqlite3_column_int(stmt, 22); + auto const inletDiameter = sqlite3_column_double(stmt, 23); + auto const weight = sqlite3_column_double(stmt, 24); + auto const outletDiameter = sqlite3_column_double(stmt, 25); + auto const percentageOfSchedule = sqlite3_column_double(stmt, 26); + auto const dailyPumpCapacity = sqlite3_column_double(stmt, 27); + auto const measuredPumpCapacity = sqlite3_column_double(stmt, 28); + auto const pumpPerformance = sqlite3_column_double(stmt, 29); + auto const staticSuctionHead = sqlite3_column_double(stmt, 30); + auto const staticDischargeHead = sqlite3_column_double(stmt, 31); + auto const fluidDensity = sqlite3_column_double(stmt, 32); + auto const lengthOfDischargePipe = sqlite3_column_double(stmt, 33); + auto const pipeDesignFrictionLosses = sqlite3_column_double(stmt, 34); + auto const maxWorkingPressure = sqlite3_column_double(stmt, 35); + auto const maxAmbientTemperature = sqlite3_column_double(stmt, 36); + auto const maxSuctionLift = sqlite3_column_double(stmt, 37); + auto const displacement = sqlite3_column_double(stmt, 38); + auto const startingTorque = sqlite3_column_double(stmt, 39); + auto const ratedSpeed = sqlite3_column_double(stmt, 40); + auto const shaftDiameter = sqlite3_column_double(stmt, 41); + auto const impellerDiameter = sqlite3_column_double(stmt, 42); + auto const efficiency = sqlite3_column_double(stmt, 43); + auto const output60Hz = sqlite3_column_double(stmt, 44); + auto const minFlowSize = sqlite3_column_double(stmt, 45); + auto const pumpSize = sqlite3_column_double(stmt, 46); + auto const outOfService = static_cast(sqlite3_column_int(stmt, 47)); + + auto pump = PumpData(manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService); + pump.setId(dbId); + return pump; + }; + return get_object(m_pump_data_select_single_stmt, id, cb); +} + void SQLite::create_select_stmt() { std::string const select_solid_load_charge_materials = From 633d493776bec326d92a8b91ff220885b626913b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Jan 2020 14:31:22 -0500 Subject: [PATCH 007/217] Updated SQLite.cpp --- src/sqlite/SQLite.cpp | 146 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 99b35e34..a8d256d2 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -828,6 +828,47 @@ void SQLite::create_select_stmt() WHERE sid = 1)"; prepare_statement(m_wall_losses_surface_select_custom_stmt, select_custom_wall_losses_surface); + + std::string const select_pump_data = + R"(SELECT id, sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService + FROM pump_data)"; + + prepare_statement(m_pump_data_select_stmt, select_pump_data); + + std::string const select_single_pump_data = + R"(SELECT id, sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService + FROM pump_data + WHERE id = ?)"; + + prepare_statement(m_pump_data_select_single_stmt, select_single_pump_data); + + std::string const select_custom_pump_data = + R"(SELECT id, sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService + FROM pump_data + WHERE sid = 1)"; + + prepare_statement(m_pump_data_select_custom_stmt, select_custom_pump_data); } void SQLite::create_update_and_delete_stmt() { @@ -916,6 +957,25 @@ void SQLite::create_update_and_delete_stmt() { WHERE id=? AND sid = 1)"; prepare_statement(m_wall_losses_surface_update_stmt, update_wall_losses_surface); + + std::string const delete_pump_data = + R"(DELETE from pump_data where id=? and sid=1)"; + + prepare_statement(m_pump_data_delete_stmt, delete_pump_data); + + std::string const update_pump_data = + R"(UPDATE pump_data + SET manufacturer=?, model=?, type=?, serialNumber=?, status=?, pumpType=?, radialBearingType=?, thrustBearingType=?, + shaftOrientation=?, shaftSealType=?, fluidType=?, priority=?, driveType=?, flangeConnectionClass=?, + flangeConnectionSize=?, numShafts=?, speed=?, numStages=?, yearlyOperatingHours=?, yearInstalled=?, + finalMotorRpm=?, inletDiameter=?, weight=?, outletDiameter=?, percentageOfSchedule=?, dailyPumpCapacity=?, + measuredPumpCapacity=?, pumpPerformance=?, staticSuctionHead=?, staticDischargeHead=?, fluidDensity=?, + lengthOfDischargePipe=?, pipeDesignFrictionLosses=?, maxWorkingPressure=?, maxAmbientTemperature=?, + maxSuctionLift=?, displacement=?, startingTorque=?, ratedSpeed=?, shaftDiameter=?, impellerDiameter=?, + efficiency=?, output60Hz=?, minFlowSize=?, pumpSize=?, outOfService=? + WHERE id=? AND sid = 1)"; + + prepare_statement(m_pump_data_update_stmt, update_pump_data); } void SQLite::create_insert_stmt() { @@ -964,6 +1024,21 @@ void SQLite::create_insert_stmt() { VALUES (?,?,?))"; prepare_statement(m_wall_losses_surface_insert_stmt, wall_losses_surface_insert_sql); + + const std::string pump_data_insert_sql = + R"(INSERT INTO pump_data(sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))"; + + // 47 entries + + prepare_statement(m_pump_data_insert_stmt, pump_data_insert_sql); } @@ -1073,6 +1148,68 @@ void SQLite::create_tables() );)"; execute_command(wall_losses_surface_table_sql); + + const std::string pump_table_sql = + R"(CREATE TABLE IF NOT EXISTS pump_data ( + id integer PRIMARY KEY AUTOINCREMENT, + sid integer NOT NULL, + manufacturer text NOT NULL, + model text NOT NULL, + type text NOT NULL, + serialNumber text NOT NULL, + status text NOT NULL, + pumpType text NOT NULL, + radialBearingType text NOT NULL, + thrustBearingType text NOT NULL, + shaftOrientation text NOT NULL, + shaftSealType text NOT NULL, + fluidType text NOT NULL, + priority text NOT NULL, + driveType text NOT NULL, + flangeConnectionClass text NOT NULL, + flangeConnectionSize text NOT NULL, + numShafts integer NOT NULL, + speed integer NOT NULL, + numStages integer NOT NULL, + yearlyOperatingHours integer NOT NULL, + yearInstalled integer NOT NULL, + finalMotorRpm integer NOT NULL, + inletDiameter real NOT NULL, + weight real NOT NULL, + outletDiameter real NOT NULL, + percentageOfSchedule real NOT NULL, + dailyPumpCapacity real NOT NULL, + measuredPumpCapacity real NOT NULL, + pumpPerformance real NOT NULL, + staticSuctionHead real NOT NULL, + staticDischargeHead real NOT NULL, + fluidDensity real NOT NULL, + lengthOfDischargePipe real NOT NULL, + pipeDesignFrictionLosses real NOT NULL, + maxWorkingPressure real NOT NULL, + maxAmbientTemperature real NOT NULL, + maxSuctionLift real NOT NULL, + displacement real NOT NULL, + startingTorque real NOT NULL, + ratedSpeed real NOT NULL, + shaftDiameter real NOT NULL, + impellerDiameter real NOT NULL, + efficiency real NOT NULL, + output60Hz real NOT NULL, + minFlowSize real NOT NULL, + pumpSize real NOT NULL, + outOfService integer NOT NULL, + UNIQUE (manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, + shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, + flangeConnectionSize, numShafts, speed, numStages, yearlyOperatingHours, yearInstalled, + finalMotorRpm, inletDiameter, weight, outletDiameter, percentageOfSchedule, dailyPumpCapacity, + measuredPumpCapacity, pumpPerformance, staticSuctionHead, staticDischargeHead, fluidDensity, + lengthOfDischargePipe, pipeDesignFrictionLosses, maxWorkingPressure, maxAmbientTemperature, + maxSuctionLift, displacement, startingTorque, ratedSpeed, shaftDiameter, impellerDiameter, + efficiency, output60Hz, minFlowSize, pumpSize, outOfService) + );)"; + + execute_command(pump_table_sql); } void SQLite::insert_default_data() @@ -1098,6 +1235,15 @@ void SQLite::insert_default_data() for( auto const & surface : get_default_wall_losses_surface() ) { insert_wall_losses_surface(surface); } + /* + for( auto const & pump : get_default_pump_data() ) { + insert_pump_data(pump); + //auto testing = getPumpDataById(1); + //auto hello = 0; + + } + */ + } bool SQLite::insert_solid_load_charge_materials(SolidLoadChargeMaterial const & material) From 3396291ba2cd69225c7b5f5ae3e7796f556c8f71 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 28 Jan 2020 09:28:13 -0500 Subject: [PATCH 008/217] Added insert/update/delete functions for pumps in SQLite.cpp --- src/sqlite/SQLite.cpp | 183 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index a8d256d2..312f9072 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1666,6 +1666,189 @@ bool SQLite::updateWallLossesSurface(WallLosses const &material) { return valid_insert; } +bool SQLite::insertPumpData(PumpData const &pump) { + bind_value(m_pump_data_insert_stmt, 1, 1); + bind_value(m_pump_data_insert_stmt, 2, pump.manufacturer); + bind_value(m_pump_data_insert_stmt, 3, pump.model); + bind_value(m_pump_data_insert_stmt, 4, pump.type); + bind_value(m_pump_data_insert_stmt, 5, pump.serialNumber); + bind_value(m_pump_data_insert_stmt, 6, pump.status); + bind_value(m_pump_data_insert_stmt, 7, pump.pumpType); + bind_value(m_pump_data_insert_stmt, 8, pump.radialBearingType); + bind_value(m_pump_data_insert_stmt, 9, pump.thrustBearingType); + bind_value(m_pump_data_insert_stmt, 10, pump.shaftOrientation); + bind_value(m_pump_data_insert_stmt, 11, pump.shaftSealType); + bind_value(m_pump_data_insert_stmt, 12, pump.fluidType); + bind_value(m_pump_data_insert_stmt, 13, pump.priority); + bind_value(m_pump_data_insert_stmt, 14, pump.driveType); + bind_value(m_pump_data_insert_stmt, 15, pump.flangeConnectionClass); + bind_value(m_pump_data_insert_stmt, 16, pump.flangeConnectionSize); + bind_value(m_pump_data_insert_stmt, 17, pump.numShafts); + bind_value(m_pump_data_insert_stmt, 18, pump.speed); + bind_value(m_pump_data_insert_stmt, 19, pump.numStages); + bind_value(m_pump_data_insert_stmt, 20, pump.yearlyOperatingHours); + bind_value(m_pump_data_insert_stmt, 21, pump.yearInstalled); + bind_value(m_pump_data_insert_stmt, 22, pump.finalMotorRpm); + bind_value(m_pump_data_insert_stmt, 23, pump.inletDiameter); + bind_value(m_pump_data_insert_stmt, 24, pump.weight); + bind_value(m_pump_data_insert_stmt, 25, pump.outletDiameter); + bind_value(m_pump_data_insert_stmt, 26, pump.percentageOfSchedule); + bind_value(m_pump_data_insert_stmt, 27, pump.dailyPumpCapacity); + bind_value(m_pump_data_insert_stmt, 28, pump.measuredPumpCapacity); + bind_value(m_pump_data_insert_stmt, 29, pump.pumpPerformance); + bind_value(m_pump_data_insert_stmt, 30, pump.staticSuctionHead); + bind_value(m_pump_data_insert_stmt, 31, pump.staticDischargeHead); + bind_value(m_pump_data_insert_stmt, 32, pump.fluidDensity); + bind_value(m_pump_data_insert_stmt, 33, pump.lengthOfDischargePipe); + bind_value(m_pump_data_insert_stmt, 34, pump.pipeDesignFrictionLosses); + bind_value(m_pump_data_insert_stmt, 35, pump.maxWorkingPressure); + bind_value(m_pump_data_insert_stmt, 36, pump.maxAmbientTemperature); + bind_value(m_pump_data_insert_stmt, 37, pump.maxSuctionLift); + bind_value(m_pump_data_insert_stmt, 38, pump.displacement); + bind_value(m_pump_data_insert_stmt, 39, pump.startingTorque); + bind_value(m_pump_data_insert_stmt, 40, pump.ratedSpeed); + bind_value(m_pump_data_insert_stmt, 41, pump.shaftDiameter); + bind_value(m_pump_data_insert_stmt, 42, pump.impellerDiameter); + bind_value(m_pump_data_insert_stmt, 43, pump.efficiency); + bind_value(m_pump_data_insert_stmt, 44, pump.output60Hz); + bind_value(m_pump_data_insert_stmt, 45, pump.minFlowSize); + bind_value(m_pump_data_insert_stmt, 46, pump.pumpSize); + bind_value(m_pump_data_insert_stmt, 47, pump.outOfService); + + int rc = step_command(m_pump_data_insert_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_pump_data_insert_stmt); + return valid_insert; +} + +bool SQLite::deletePumpData(int id) { + if (isDefaultMaterial(id, get_default_pump_data().size())) { + return false; + } + bind_value(m_pump_data_delete_stmt, 1, id); + int rc = step_command(m_pump_data_delete_stmt); + bool valid_command = step_validity(rc); + reset_command(m_pump_data_delete_stmt); + return valid_command; +} + +bool SQLite::updatePumpData(PumpData const &pump) { + if (isDefaultMaterial(pump.id, get_default_pump_data().size())) { + return false; + } + + bind_value(m_pump_data_update_stmt, 1, pump.manufacturer); + bind_value(m_pump_data_update_stmt, 2, pump.model); + bind_value(m_pump_data_update_stmt, 3, pump.type); + bind_value(m_pump_data_update_stmt, 4, pump.serialNumber); + bind_value(m_pump_data_update_stmt, 5, pump.status); + bind_value(m_pump_data_update_stmt, 6, pump.pumpType); + bind_value(m_pump_data_update_stmt, 7, pump.radialBearingType); + bind_value(m_pump_data_update_stmt, 8, pump.thrustBearingType); + bind_value(m_pump_data_update_stmt, 9, pump.shaftOrientation); + bind_value(m_pump_data_update_stmt, 10, pump.shaftSealType); + bind_value(m_pump_data_update_stmt, 11, pump.fluidType); + bind_value(m_pump_data_update_stmt, 12, pump.priority); + bind_value(m_pump_data_update_stmt, 13, pump.driveType); + bind_value(m_pump_data_update_stmt, 14, pump.flangeConnectionClass); + bind_value(m_pump_data_update_stmt, 15, pump.flangeConnectionSize); + bind_value(m_pump_data_update_stmt, 16, pump.numShafts); + bind_value(m_pump_data_update_stmt, 17, pump.speed); + bind_value(m_pump_data_update_stmt, 18, pump.numStages); + bind_value(m_pump_data_update_stmt, 19, pump.yearlyOperatingHours); + bind_value(m_pump_data_update_stmt, 20, pump.yearInstalled); + bind_value(m_pump_data_update_stmt, 21, pump.finalMotorRpm); + bind_value(m_pump_data_update_stmt, 22, pump.inletDiameter); + bind_value(m_pump_data_update_stmt, 23, pump.weight); + bind_value(m_pump_data_update_stmt, 24, pump.outletDiameter); + bind_value(m_pump_data_update_stmt, 25, pump.percentageOfSchedule); + bind_value(m_pump_data_update_stmt, 26, pump.dailyPumpCapacity); + bind_value(m_pump_data_update_stmt, 27, pump.measuredPumpCapacity); + bind_value(m_pump_data_update_stmt, 28, pump.pumpPerformance); + bind_value(m_pump_data_update_stmt, 29, pump.staticSuctionHead); + bind_value(m_pump_data_update_stmt, 30, pump.staticDischargeHead); + bind_value(m_pump_data_update_stmt, 31, pump.fluidDensity); + bind_value(m_pump_data_update_stmt, 32, pump.lengthOfDischargePipe); + bind_value(m_pump_data_update_stmt, 33, pump.pipeDesignFrictionLosses); + bind_value(m_pump_data_update_stmt, 34, pump.maxWorkingPressure); + bind_value(m_pump_data_update_stmt, 35, pump.maxAmbientTemperature); + bind_value(m_pump_data_update_stmt, 36, pump.maxSuctionLift); + bind_value(m_pump_data_update_stmt, 37, pump.displacement); + bind_value(m_pump_data_update_stmt, 38, pump.startingTorque); + bind_value(m_pump_data_update_stmt, 39, pump.ratedSpeed); + bind_value(m_pump_data_update_stmt, 40, pump.shaftDiameter); + bind_value(m_pump_data_update_stmt, 41, pump.impellerDiameter); + bind_value(m_pump_data_update_stmt, 42, pump.efficiency); + bind_value(m_pump_data_update_stmt, 43, pump.output60Hz); + bind_value(m_pump_data_update_stmt, 44, pump.minFlowSize); + bind_value(m_pump_data_update_stmt, 45, pump.pumpSize); + bind_value(m_pump_data_update_stmt, 46, pump.outOfService); + + int rc = step_command(m_pump_data_update_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_pump_data_update_stmt); + return valid_insert; +} + +bool SQLite::insert_pump_data(PumpData const &pump) { + if (isDefaultMaterial(pump.id, get_default_pump_data().size())) { + return false; + } + + bind_value(m_pump_data_insert_stmt, 1, 0); + bind_value(m_pump_data_insert_stmt, 2, pump.manufacturer); + bind_value(m_pump_data_insert_stmt, 3, pump.model); + bind_value(m_pump_data_insert_stmt, 4, pump.type); + bind_value(m_pump_data_insert_stmt, 5, pump.serialNumber); + bind_value(m_pump_data_insert_stmt, 6, pump.status); + bind_value(m_pump_data_insert_stmt, 7, pump.pumpType); + bind_value(m_pump_data_insert_stmt, 8, pump.radialBearingType); + bind_value(m_pump_data_insert_stmt, 9, pump.thrustBearingType); + bind_value(m_pump_data_insert_stmt, 10, pump.shaftOrientation); + bind_value(m_pump_data_insert_stmt, 11, pump.shaftSealType); + bind_value(m_pump_data_insert_stmt, 12, pump.fluidType); + bind_value(m_pump_data_insert_stmt, 13, pump.priority); + bind_value(m_pump_data_insert_stmt, 14, pump.driveType); + bind_value(m_pump_data_insert_stmt, 15, pump.flangeConnectionClass); + bind_value(m_pump_data_insert_stmt, 16, pump.flangeConnectionSize); + bind_value(m_pump_data_insert_stmt, 17, pump.numShafts); + bind_value(m_pump_data_insert_stmt, 18, pump.speed); + bind_value(m_pump_data_insert_stmt, 19, pump.numStages); + bind_value(m_pump_data_insert_stmt, 20, pump.yearlyOperatingHours); + bind_value(m_pump_data_insert_stmt, 21, pump.yearInstalled); + bind_value(m_pump_data_insert_stmt, 22, pump.finalMotorRpm); + bind_value(m_pump_data_insert_stmt, 23, pump.inletDiameter); + bind_value(m_pump_data_insert_stmt, 24, pump.weight); + bind_value(m_pump_data_insert_stmt, 25, pump.outletDiameter); + bind_value(m_pump_data_insert_stmt, 26, pump.percentageOfSchedule); + bind_value(m_pump_data_insert_stmt, 27, pump.dailyPumpCapacity); + bind_value(m_pump_data_insert_stmt, 28, pump.measuredPumpCapacity); + bind_value(m_pump_data_insert_stmt, 29, pump.pumpPerformance); + bind_value(m_pump_data_insert_stmt, 30, pump.staticSuctionHead); + bind_value(m_pump_data_insert_stmt, 31, pump.staticDischargeHead); + bind_value(m_pump_data_insert_stmt, 32, pump.fluidDensity); + bind_value(m_pump_data_insert_stmt, 33, pump.lengthOfDischargePipe); + bind_value(m_pump_data_insert_stmt, 34, pump.pipeDesignFrictionLosses); + bind_value(m_pump_data_insert_stmt, 35, pump.maxWorkingPressure); + bind_value(m_pump_data_insert_stmt, 36, pump.maxAmbientTemperature); + bind_value(m_pump_data_insert_stmt, 37, pump.maxSuctionLift); + bind_value(m_pump_data_insert_stmt, 38, pump.displacement); + bind_value(m_pump_data_insert_stmt, 39, pump.startingTorque); + bind_value(m_pump_data_insert_stmt, 40, pump.ratedSpeed); + bind_value(m_pump_data_insert_stmt, 41, pump.shaftDiameter); + bind_value(m_pump_data_insert_stmt, 42, pump.impellerDiameter); + bind_value(m_pump_data_insert_stmt, 43, pump.efficiency); + bind_value(m_pump_data_insert_stmt, 44, pump.output60Hz); + bind_value(m_pump_data_insert_stmt, 45, pump.minFlowSize); + bind_value(m_pump_data_insert_stmt, 46, pump.pumpSize); + bind_value(m_pump_data_insert_stmt, 47, pump.outOfService); + + int rc = step_command(m_pump_data_insert_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_pump_data_insert_stmt); + return valid_insert; +} + SQLiteWrapper::SQLiteWrapper( std::shared_ptr const & db ) : m_db(db) From 9cb6ef01a303db96c43e4062d2c02d97bb7298c0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 28 Jan 2020 12:02:05 -0500 Subject: [PATCH 009/217] Debugging Pump Table --- bindings/db.h | 1 + src/sqlite/SQLite.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/bindings/db.h b/bindings/db.h index d9b5aee6..d8cb6a90 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -14,6 +14,7 @@ #include #include #include +#include using namespace Nan; using namespace v8; diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 312f9072..9930c8e1 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1234,12 +1234,14 @@ void SQLite::insert_default_data() } for( auto const & surface : get_default_wall_losses_surface() ) { insert_wall_losses_surface(surface); + //getWallLossesSurfaceById(1); } /* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); //auto testing = getPumpDataById(1); //auto hello = 0; + //std::cout << "TEST"; } */ From e983fcc826ca83406f0c9cfd20a5e36def7a7f81 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 29 Jan 2020 13:54:21 -0500 Subject: [PATCH 010/217] Updated binding.gyp --- binding.gyp | 4 +++- src/sqlite/SQLite.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index 039bd5ca..26753bb8 100644 --- a/binding.gyp +++ b/binding.gyp @@ -168,12 +168,14 @@ }, { "target_name": "db", - 'include_dirs': ['include', 'include/sqlite', 'third_party/sqlite', 'include/calculator/losses', 'include/calculator/motor', + 'include_dirs': ['include', 'include/sqlite', 'third_party/sqlite', 'include/calculator/losses', + 'include/calculator/motor', 'include/calculator/pump', "'src/calculator/losses/'+f).join(' '))\")", "'src/sqlite/'+f).join(' '))\")", ], diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 9930c8e1..dea577f3 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,8 @@ SQLite::SQLite(std::string const & db_name, bool init_db) create_select_stmt(); create_update_and_delete_stmt(); + + //auto test = get_default_pump_data(); } SQLite::~SQLite() @@ -1245,6 +1248,7 @@ void SQLite::insert_default_data() } */ + auto test = get_default_pump_data(); } From 1c3ec8b91310e29bccfa913bcaaa4e724ea6c3be Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 29 Jan 2020 14:00:41 -0500 Subject: [PATCH 011/217] Pump table creation now compiling --- src/sqlite/SQLite.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index dea577f3..91b60edc 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -43,8 +43,6 @@ SQLite::SQLite(std::string const & db_name, bool init_db) create_select_stmt(); create_update_and_delete_stmt(); - - //auto test = get_default_pump_data(); } SQLite::~SQLite() @@ -1239,7 +1237,7 @@ void SQLite::insert_default_data() insert_wall_losses_surface(surface); //getWallLossesSurfaceById(1); } - /* + ///* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); //auto testing = getPumpDataById(1); @@ -1247,8 +1245,8 @@ void SQLite::insert_default_data() //std::cout << "TEST"; } - */ - auto test = get_default_pump_data(); + //*/ + //auto test = get_default_pump_data(); } From feae06fb08d51493b8e06b9615594edc410da451 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 29 Jan 2020 14:14:36 -0500 Subject: [PATCH 012/217] Added debug.txt --- debug.txt | 0 src/sqlite/SQLite.cpp | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 debug.txt diff --git a/debug.txt b/debug.txt new file mode 100644 index 00000000..e69de29b diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 91b60edc..ab7ddff2 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1237,7 +1237,7 @@ void SQLite::insert_default_data() insert_wall_losses_surface(surface); //getWallLossesSurfaceById(1); } - ///* + /* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); //auto testing = getPumpDataById(1); @@ -1245,8 +1245,24 @@ void SQLite::insert_default_data() //std::cout << "TEST"; } - //*/ - //auto test = get_default_pump_data(); + */ + auto test = get_default_pump_data(); + + std::ofstream ofs("debug.txt"); + ofs << "get_default_pump_data() returned a size of " << test.size(); + auto index = 0; + for( auto const & pump : get_default_pump_data() ) { + ofs << " pump: " << pump.manufacturer << " pump.id (uninitialized prob): " << pump.id << std::endl; + auto result = insert_pump_data(pump); + ofs << " result: " << result << std::endl; + auto all_pumps_so_far = getPumpData(); + ofs << "pump count as of now: " << all_pumps_so_far.size() << std::endl << std::endl; + for( auto const & pump_inner : all_pumps_so_far ) { + ofs << " pump_inner: " << pump_inner.manufacturer << " pump_inner.id (should be initialized): " << pump_inner.id << std::endl; + } + ofs << std::endl << std::endl; + } + auto hello = 0; } From 7df4a5e9f7ac03a1c50ad3e771ace107f660a84a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 29 Jan 2020 14:45:31 -0500 Subject: [PATCH 013/217] Updated SQLite.cpp --- Dockerfile | 4 +++- include/sqlite/PumpData.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 590801e4..31d1728a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,8 @@ RUN node-gyp rebuild RUN npm run test RUN npm run at + +RUN cat debug.txt #-------------------------------------------------------------- -WORKDIR /home/ +#WORKDIR /home/ diff --git a/include/sqlite/PumpData.h b/include/sqlite/PumpData.h index fcad711b..e8821b0e 100644 --- a/include/sqlite/PumpData.h +++ b/include/sqlite/PumpData.h @@ -10,6 +10,12 @@ std::vector SQLite::get_default_pump_data() { "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 + }, + { + "manufacturer2", "model2", "type2", "serialNumber2", "status2", "pumpType2", "radialBearingType2", + "thrustBearingType2", "shaftOrientation2", "shaftSealType2", "fluidType2", "priority2", "driveType2", + "flangeConnectionClass2", "flangeConnectionSize2", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 } }; } From b855b0568f7239ad0b4ff6197318e120ee7e8f59 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 30 Jan 2020 11:19:19 -0500 Subject: [PATCH 014/217] Added comments to SQLite.cpp --- src/sqlite/SQLite.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index ab7ddff2..05d0cf0d 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1237,7 +1237,7 @@ void SQLite::insert_default_data() insert_wall_losses_surface(surface); //getWallLossesSurfaceById(1); } - /* + ///* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); //auto testing = getPumpDataById(1); @@ -1245,7 +1245,8 @@ void SQLite::insert_default_data() //std::cout << "TEST"; } - */ + //*/ + /* auto test = get_default_pump_data(); std::ofstream ofs("debug.txt"); @@ -1263,6 +1264,7 @@ void SQLite::insert_default_data() ofs << std::endl << std::endl; } auto hello = 0; + */ } @@ -1687,7 +1689,7 @@ bool SQLite::updateWallLossesSurface(WallLosses const &material) { } bool SQLite::insertPumpData(PumpData const &pump) { - bind_value(m_pump_data_insert_stmt, 1, 1); + bind_value(m_pump_data_insert_stmt, 1, 1); // sid bind_value(m_pump_data_insert_stmt, 2, pump.manufacturer); bind_value(m_pump_data_insert_stmt, 3, pump.model); bind_value(m_pump_data_insert_stmt, 4, pump.type); @@ -1803,6 +1805,7 @@ bool SQLite::updatePumpData(PumpData const &pump) { bind_value(m_pump_data_update_stmt, 44, pump.minFlowSize); bind_value(m_pump_data_update_stmt, 45, pump.pumpSize); bind_value(m_pump_data_update_stmt, 46, pump.outOfService); + bind_value(m_pump_data_update_stmt, 47, pump.id); int rc = step_command(m_pump_data_update_stmt); bool valid_insert = step_validity(rc); @@ -1815,7 +1818,7 @@ bool SQLite::insert_pump_data(PumpData const &pump) { return false; } - bind_value(m_pump_data_insert_stmt, 1, 0); + bind_value(m_pump_data_insert_stmt, 1, 0); // sid bind_value(m_pump_data_insert_stmt, 2, pump.manufacturer); bind_value(m_pump_data_insert_stmt, 3, pump.model); bind_value(m_pump_data_insert_stmt, 4, pump.type); From 7a843fd610d27d9a15f42e37e3e4f9480fd44dbc Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 30 Jan 2020 13:30:25 -0500 Subject: [PATCH 015/217] Added debugging code to SQLite.cpp --- src/sqlite/SQLite.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 05d0cf0d..fb1bb7ae 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1246,10 +1246,11 @@ void SQLite::insert_default_data() } //*/ + //std::ofstream ofs("debug.txt"); /* auto test = get_default_pump_data(); - std::ofstream ofs("debug.txt"); + //std::ofstream ofs("debug.txt"); ofs << "get_default_pump_data() returned a size of " << test.size(); auto index = 0; for( auto const & pump : get_default_pump_data() ) { @@ -1266,6 +1267,21 @@ void SQLite::insert_default_data() auto hello = 0; */ + /* + //SolidLoadChargeMaterial slcm("Substance", 0.247910198231111, 887, 0.2501, 1117); + //auto result = insert_solid_load_charge_materials(slcm); + //ofs << "result: " << result << std::endl; + //auto slcm_data = get_default_solid_load_charge_materials(); + auto slcm_data = getSolidLoadChargeMaterials(); + //auto slcm_data_single = getSolidLoadChargeMaterialById(0); + ofs << "getSolidLoadChargeMaterials() returned a size of " << slcm_data.size(); + ofs << std::endl << std::endl; + for( auto const & slcm : slcm_data ) { + ofs << " slcm: " << slcm.substance << " slcm.id: " << slcm.id << std::endl; + } + //ofs << "getSolidLoadChargeMaterialById(0) returned substance of " << slcm_data_single.substance << std::endl; + */ + } bool SQLite::insert_solid_load_charge_materials(SolidLoadChargeMaterial const & material) From fbe7a8507aa7d137363a6cab04e9dc55ababa43e Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 30 Jan 2020 15:34:00 -0500 Subject: [PATCH 016/217] Added C++ unit test for Pump Table --- include/sqlite/PumpData.h | 4 +++- tests/SQLite.unit.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/sqlite/PumpData.h b/include/sqlite/PumpData.h index e8821b0e..9e0a233c 100644 --- a/include/sqlite/PumpData.h +++ b/include/sqlite/PumpData.h @@ -10,13 +10,15 @@ std::vector SQLite::get_default_pump_data() { "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 - }, + } + /* { "manufacturer2", "model2", "type2", "serialNumber2", "status2", "pumpType2", "radialBearingType2", "thrustBearingType2", "shaftOrientation2", "shaftSealType2", "fluidType2", "priority2", "driveType2", "flangeConnectionClass2", "flangeConnectionSize2", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 } + */ }; } diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index b98cd04b..df13b07e 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include TEST_CASE( "SQLite - getSolidLoadChargeMaterials", "[sqlite]" ) { @@ -285,6 +286,34 @@ TEST_CASE( "SQLite - update all materials", "[sqlite]" ) { CHECK(Approx(sqlite.getCustomWallLossesSurface().at(0).getConditionFactor()) == 0.5); CHECK(Approx(sqlite.getCustomWallLossesSurface().at(1).getConditionFactor()) == 0.75); } + + { + + PumpData pump1("manufacturerCustom1", "modelCustom1", "typeCustom1", "serialNumberCustom1", "statusCustom1", "pumpTypeCustom1", + "radialBearingTypeCustom1", "thrustBearingTypeCustom1", "shaftOrientationCustom1", "shaftSealTypeCustom1", "fluidTypeCustom1", + "priorityCustom1", "driveTypeCustom1", "flangeConnectionClassCustom1", "flangeConnectionSizeCustom1", 1, 2, 1, 9000, 2018, 1780, + 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1); + + PumpData pump2("manufacturerCustom2", "modelCustom2", "typeCustom2", "serialNumberCustom2", "statusCustom2", "pumpTypeCustom2", + "radialBearingTypeCustom2", "thrustBearingTypeCustom2", "shaftOrientationCustom2", "shaftSealTypeCustom2", "fluidTypeCustom2", + "priorityCustom2", "driveTypeCustom2", "flangeConnectionClassCustom2", "flangeConnectionSizeCustom2", 1, 2, 1, 9000, 2018, 1780, + 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1); + + sqlite.insertPumpData(pump1); + sqlite.insertPumpData(pump2); + + auto custom1 = sqlite.getCustomPumpData().at(0); + auto custom2 = sqlite.getCustomPumpData().at(1); + + custom1.setManufacturer("updatedManufacturerCustom1"); + custom2.setManufacturer("updatedManufacturerCustom2"); + + sqlite.updatePumpData(custom1); + sqlite.updatePumpData(custom2); + + CHECK(sqlite.getCustomPumpData().at(0).getManufacturer() == "updatedManufacturerCustom1"); + CHECK(sqlite.getCustomPumpData().at(1).getManufacturer() == "updatedManufacturerCustom2"); + } } TEST_CASE( "SQLite - deleteMaterials", "[sqlite]" ) { From c6598e59f8d70a3dd7ffb6e0322dc0a894703cab Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 30 Jan 2020 15:51:39 -0500 Subject: [PATCH 017/217] Updated SQLite.unit.cpp --- tests/SQLite.unit.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index df13b07e..0dc718a9 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -302,6 +302,15 @@ TEST_CASE( "SQLite - update all materials", "[sqlite]" ) { sqlite.insertPumpData(pump1); sqlite.insertPumpData(pump2); + /* + std::ofstream ofs("debug.txt"); + auto test = sqlite.getPumpData(); + ofs << std::endl; + ofs << "getPumpData() returned size " << test.size() << std::endl; + ofs << std::endl; + ofs.close(); + */ + auto custom1 = sqlite.getCustomPumpData().at(0); auto custom2 = sqlite.getCustomPumpData().at(1); From 6af85391d96d40fc37613cfa661cc2e0a50137ec Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 31 Jan 2020 09:09:33 -0500 Subject: [PATCH 018/217] Added delete unit test for Pump --- tests/SQLite.unit.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index 0dc718a9..06380aa8 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -426,6 +426,21 @@ TEST_CASE( "SQLite - deleteMaterials", "[sqlite]" ) { auto const output2 = sqlite.getWallLossesSurface(); CHECK( output2[output2.size() - 1].getSurface() == last ); } + + { + auto const output = sqlite.getPumpData(); + auto const last = output.back().getManufacturer(); + PumpData pump( + "throw this pump away delete", "model", "type", "serialNumber", "status", "pumpType", "radial", + "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", + "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 ); + + sqlite.insertPumpData(pump); + sqlite.deletePumpData(sqlite.getPumpData().back().getId()); + auto const output2 = sqlite.getPumpData(); + CHECK( output2[output2.size() - 1].getManufacturer() == last ); + } } //// commented because it writes to HDD From cefe6e8de979f2b72323a022165d54172e5061c2 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 31 Jan 2020 09:26:58 -0500 Subject: [PATCH 019/217] Added insert, update, and select unit test for Pump table --- tests/SQLite.unit.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index 06380aa8..dff79140 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -1149,3 +1149,88 @@ TEST_CASE( "SQLite - CustomWallLossesSurface", "[sqlite]" ) { CHECK( output[1].getConditionFactor() == expected.getConditionFactor() ); } } + +TEST_CASE( "SQLite - Pump Data inserts and updates and selects", "[sqlite][pump]" ) { + auto const compare = [](PumpData result, PumpData expected) { + CHECK(result.getManufacturer() == expected.getManufacturer()); + CHECK(result.getModel() == expected.getModel()); + CHECK(result.getType() == expected.getType()); + CHECK(result.getSerialNumber() == expected.getSerialNumber()); + CHECK(result.getStatus() == expected.getStatus()); + CHECK(result.getPumpType() == expected.getPumpType()); + CHECK(result.getRadialBearingType() == expected.getRadialBearingType()); + CHECK(result.getThrustBearingType() == expected.getThrustBearingType()); + CHECK(result.getShaftOrientation() == expected.getShaftOrientation()); + CHECK(result.getShaftSealType() == expected.getShaftSealType()); + CHECK(result.getFluidType() == expected.getFluidType()); + CHECK(result.getPriority() == expected.getPriority()); + CHECK(result.getDriveType() == expected.getDriveType()); + CHECK(result.getFlangeConnectionClass() == expected.getFlangeConnectionClass()); + CHECK(result.getFlangeConnectionSize() == expected.getFlangeConnectionSize()); + CHECK(result.getNumShafts() == expected.getNumShafts()); + CHECK(result.getSpeed() == expected.getSpeed()); + CHECK(result.getNumStages() == expected.getNumStages()); + CHECK(result.getYearlyOperatingHours() == expected.getYearlyOperatingHours()); + CHECK(result.getYearInstalled() == expected.getYearInstalled()); + CHECK(result.getFinalMotorRpm() == expected.getFinalMotorRpm()); + CHECK(result.getInletDiameter() == expected.getInletDiameter()); + CHECK(result.getWeight() == expected.getWeight()); + CHECK(result.getOutletDiameter() == expected.getOutletDiameter()); + CHECK(result.getPercentageOfSchedule() == expected.getPercentageOfSchedule()); + CHECK(result.getDailyPumpCapacity() == expected.getDailyPumpCapacity()); + CHECK(result.getMeasuredPumpCapacity() == expected.getMeasuredPumpCapacity()); + CHECK(result.getPumpPerformance() == expected.getPumpPerformance()); + CHECK(result.getStaticSuctionHead() == expected.getStaticSuctionHead()); + CHECK(result.getStaticDischargeHead() == expected.getStaticDischargeHead()); + CHECK(result.getFluidDensity() == expected.getFluidDensity()); + CHECK(result.getLengthOfDischargePipe() == expected.getLengthOfDischargePipe()); + CHECK(result.getPipeDesignFrictionLosses() == expected.getPipeDesignFrictionLosses()); + CHECK(result.getMaxWorkingPressure() == expected.getMaxWorkingPressure()); + CHECK(result.getMaxAmbientTemperature() == expected.getMaxAmbientTemperature()); + CHECK(result.getMaxSuctionLift() == expected.getMaxSuctionLift()); + CHECK(result.getDisplacement() == expected.getDisplacement()); + CHECK(result.getStartingTorque() == expected.getStartingTorque()); + CHECK(result.getRatedSpeed() == expected.getRatedSpeed()); + CHECK(result.getShaftDiameter() == expected.getShaftDiameter()); + CHECK(result.getImpellerDiameter() == expected.getImpellerDiameter()); + CHECK(result.getEfficiency() == expected.getEfficiency()); + CHECK(result.getOutput60Hz() == expected.getOutput60Hz()); + CHECK(result.getMinFlowSize() == expected.getMinFlowSize()); + CHECK(result.getPumpSize() == expected.getPumpSize()); + CHECK(result.getOutOfService() == expected.getOutOfService()); + CHECK(result.getId() == expected.getId()); + }; + + auto sqlite = SQLite(":memory:", true); +// auto sqlite = SQLite("cpp_amo_tools_suite.db", true); + + { + auto const pumps = sqlite.getPumpData(); + + auto expected = PumpData( + "manufacturer", "model", "type", "serialNumber", "status", "pumpType", "radialBearingType", + "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", + "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 ); + + expected.setId(1); + + compare(pumps.at(0), expected); + + auto pump = PumpData( + "test-manufacturer", "test-model", "test-type", "test-serialNumber", "status", "pumpType", "radialBearingType", + "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", + "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1 ); + + sqlite.insertPumpData(pump); + pump.setId(2); + compare(sqlite.getPumpData().back(), pump); + + pump = sqlite.getPumpData().back(); + pump.setManufacturer("updated"); + sqlite.updatePumpData(pump); + + compare(sqlite.getPumpData().back(), pump); + } +} From 48cc795e2ca65bf61b1e567f0f967bddda44579c Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 31 Jan 2020 13:42:13 -0500 Subject: [PATCH 020/217] Added database bindings for Pump table --- bindings/db.cpp | 15 +++++ bindings/db.h | 125 +++++++++++++++++++++++++++++++++++++ tests/js/dbBindingsTest.js | 2 + 3 files changed, 142 insertions(+) diff --git a/bindings/db.cpp b/bindings/db.cpp index f452606f..7cd084c8 100644 --- a/bindings/db.cpp +++ b/bindings/db.cpp @@ -113,6 +113,21 @@ NAN_MODULE_INIT(InitDb) { Nan::Set(target, New("updateWallLossesSurface").ToLocalChecked(), GetFunction(New(updateWallLossesSurface)).ToLocalChecked()); + + Nan::Set(target, New("selectPumps").ToLocalChecked(), + GetFunction(New(selectPumps)).ToLocalChecked()); + + Nan::Set(target, New("selectPumpById").ToLocalChecked(), + GetFunction(New(selectPumpById)).ToLocalChecked()); + + Nan::Set(target, New("insertPump").ToLocalChecked(), + GetFunction(New(insertPump)).ToLocalChecked()); + + Nan::Set(target, New("deletePump").ToLocalChecked(), + GetFunction(New(deletePump)).ToLocalChecked()); + + Nan::Set(target, New("updatePump").ToLocalChecked(), + GetFunction(New(updatePump)).ToLocalChecked()); } NODE_MODULE(db, InitDb) diff --git a/bindings/db.h b/bindings/db.h index d8cb6a90..ae6bc948 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -59,6 +59,56 @@ inline void SetObj(Local &obj, const std::string &key, const std::string Nan::Set(obj, Nan::New(key).ToLocalChecked(), Nan::New(val).ToLocalChecked()); } +void SetPumpData(Local & obj, const PumpData & pump) { + SetObj(obj, "id", pump.getId()); + SetObj(obj, "manufacturer", pump.getManufacturer()); + SetObj(obj, "model", pump.getModel()); + SetObj(obj, "type", pump.getType()); + SetObj(obj, "serialNumber", pump.getSerialNumber()); + SetObj(obj, "status", pump.getStatus()); + SetObj(obj, "pumpType", pump.getPumpType()); + SetObj(obj, "radialBearingType", pump.getRadialBearingType()); + SetObj(obj, "thrustBearingType", pump.getThrustBearingType()); + SetObj(obj, "shaftOrientation", pump.getShaftOrientation()); + SetObj(obj, "shaftSealType", pump.getShaftSealType()); + SetObj(obj, "fluidType", pump.getFluidType()); + SetObj(obj, "priority", pump.getPriority()); + SetObj(obj, "driveType", pump.getDriveType()); + SetObj(obj, "flangeConnectionClass", pump.getFlangeConnectionClass()); + SetObj(obj, "flangeConnectionSize", pump.getFlangeConnectionSize()); + SetObj(obj, "numShafts", pump.getNumShafts()); + SetObj(obj, "speed", pump.getSpeed()); + SetObj(obj, "numStages", pump.getNumStages()); + SetObj(obj, "yearlyOperatingHours", pump.getYearlyOperatingHours()); + SetObj(obj, "yearInstalled", pump.getYearInstalled()); + SetObj(obj, "finalMotorRpm", pump.getFinalMotorRpm()); + SetObj(obj, "inletDiameter", pump.getInletDiameter()); + SetObj(obj, "weight", pump.getWeight()); + SetObj(obj, "outletDiameter", pump.getOutletDiameter()); + SetObj(obj, "percentageOfSchedule", pump.getPercentageOfSchedule()); + SetObj(obj, "dailyPumpCapacity", pump.getDailyPumpCapacity()); + SetObj(obj, "measuredPumpCapacity", pump.getMeasuredPumpCapacity()); + SetObj(obj, "pumpPerformance", pump.getPumpPerformance()); + SetObj(obj, "staticSuctionHead", pump.getStaticSuctionHead()); + SetObj(obj, "staticDischargeHead", pump.getStaticDischargeHead()); + SetObj(obj, "fluidDensity", pump.getFluidDensity()); + SetObj(obj, "lengthOfDischargePipe", pump.getLengthOfDischargePipe()); + SetObj(obj, "pipeDesignFrictionLosses", pump.getPipeDesignFrictionLosses()); + SetObj(obj, "maxWorkingPressure", pump.getMaxWorkingPressure()); + SetObj(obj, "maxAmbientTemperature", pump.getMaxAmbientTemperature()); + SetObj(obj, "maxSuctionLift", pump.getMaxSuctionLift()); + SetObj(obj, "displacement", pump.getDisplacement()); + SetObj(obj, "startingTorque", pump.getStartingTorque()); + SetObj(obj, "ratedSpeed", pump.getRatedSpeed()); + SetObj(obj, "shaftDiameter", pump.getShaftDiameter()); + SetObj(obj, "impellerDiameter", pump.getImpellerDiameter()); + SetObj(obj, "efficiency", pump.getEfficiency()); + SetObj(obj, "output60Hz", pump.getOutput60Hz()); + SetObj(obj, "minFlowSize", pump.getMinFlowSize()); + SetObj(obj, "pumpSize", pump.getPumpSize()); + SetObj(obj, "outOfService", pump.getOutOfService()); +} + // when creating sqlite, add table that has history, put in tools-suite number and the date so that we know where db's came from // so data is version, timestamp, comment - "initial file based release" // to save the backup, @@ -713,4 +763,79 @@ NAN_METHOD(selectWallLossesSurfaceById) info.GetReturnValue().Set(obj); }; +NAN_METHOD(selectPumps) { + auto const pumps = sql->getPumpData(); // TODO this returns 0 pumps confirmed, but doesn't in C++. I don't think I can do anything else here anymore. + + auto pumpsNan = Nan::New(); + for (std::size_t i = 0; i < pumps.size(); i++) { + Local pump = Nan::New(); + SetPumpData(pump, pumps[i]); + Nan::Set(pumpsNan, i, pump); + } + + info.GetReturnValue().Set(pumpsNan); +}; + +NAN_METHOD(selectPumpById) { + Local pump = Nan::New(); + try { + //SetPumpData(pump, sql->getPumpDataById(static_cast(info[0].FromJust()))); + SetPumpData(pump, sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust()))); + } catch (std::runtime_error const & e) { + std::string const what = e.what(); + ThrowError(std::string("std::runtime_error thrown in selectPumpById - db.h: " + what).c_str()); + } + info.GetReturnValue().Set(pump); +}; + +NAN_METHOD(insertPump) { + //inp = info[0]->ToObject(); + inp = Nan::To(info[0]).ToLocalChecked(); + + PumpData pump( + GetStr("manufacturer"), GetStr("model"), GetStr("type"), GetStr("serialNumber"), GetStr("status"), + GetStr("pumpType"), GetStr("radialBearingType"), GetStr("thrustBearingType"), GetStr("shaftOrientation"), + GetStr("shaftSealType"), GetStr("fluidType"), GetStr("priority"), GetStr("driveType"), + GetStr("flangeConnectionClass"), GetStr("flangeConnectionSize"), Get("numShafts"), Get("speed"), + Get("numStages"), Get("yearlyOperatingHours"), Get("yearInstalled"), Get("finalMotorRpm"), + Get("inletDiameter"), Get("weight"), Get("outletDiameter"), Get("percentageOfSchedule"), + Get("dailyPumpCapacity"), Get("measuredPumpCapacity"), Get("pumpPerformance"), Get("staticSuctionHead"), + Get("staticDischargeHead"), Get("fluidDensity"), Get("lengthOfDischargePipe"), Get("pipeDesignFrictionLosses"), + Get("maxWorkingPressure"), Get("maxAmbientTemperature"), Get("maxSuctionLift"), Get("displacement"), + Get("startingTorque"), Get("ratedSpeed"), Get("shaftDiameter"), Get("impellerDiameter"), + Get("efficiency"), Get("output60Hz"), Get("minFlowSize"), Get("pumpSize"), Get("outOfService") + ); + bool success = sql->insertPumpData(pump); + info.GetReturnValue().Set(success); +}; + +NAN_METHOD(deletePump) { + //bool success = sql->deletePumpData(static_cast(info[0].FromJust())); + bool success = sql->deletePumpData(static_cast(Nan::To(info[0]).FromJust())); + info.GetReturnValue().Set(success); +}; + +NAN_METHOD(updatePump) { + //inp = info[0]->ToObject(); + inp = Nan::To(info[0]).ToLocalChecked(); + + PumpData pump( + GetStr("manufacturer"), GetStr("model"), GetStr("type"), GetStr("serialNumber"), GetStr("status"), + GetStr("pumpType"), GetStr("radialBearingType"), GetStr("thrustBearingType"), + GetStr("shaftOrientation"), GetStr("shaftSealType"), GetStr("fluidType"), GetStr("priority"), + GetStr("driveType"), GetStr("flangeConnectionClass"), GetStr("flangeConnectionSize"), Get("numShafts"), + Get("speed"), Get("numStages"), Get("yearlyOperatingHours"), Get("yearInstalled"), Get("finalMotorRpm"), + Get("inletDiameter"), Get("weight"), Get("outletDiameter"), Get("percentageOfSchedule"), Get("dailyPumpCapacity"), + Get("measuredPumpCapacity"), Get("pumpPerformance"), Get("staticSuctionHead"), Get("staticDischargeHead"), + Get("fluidDensity"), Get("lengthOfDischargePipe"), Get("pipeDesignFrictionLosses"), Get("maxWorkingPressure"), + Get("maxAmbientTemperature"), Get("maxSuctionLift"), Get("displacement"), Get("startingTorque"), + Get("ratedSpeed"), Get("shaftDiameter"), Get("impellerDiameter"), Get("efficiency"), + Get("output60Hz"), Get("minFlowSize"), Get("pumpSize"), Get("outOfService") + ); + + pump.setId(Get("id")); + bool success = sql->updatePumpData(pump); + info.GetReturnValue().Set(success); +}; + #endif //AMO_TOOLS_SUITE_DB_H diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index a2293a7b..ac8a36ce 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -482,6 +482,8 @@ test('dbInsertWallLossesSurface', function (t) { t.equal(res[size].conditionFactor, obj2.conditionFactor, res[size].conditionFactor + " != " + obj2.conditionFactor); }); +// PUMP TEST HERE + test('dbDeletions', function (t) { t.plan(7); bindings.startup(); From 14a1d852e43c5592168f35bb85f102f8f1206ef4 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 31 Jan 2020 16:10:37 -0500 Subject: [PATCH 021/217] Added dbSelectPumpData unit test to dbBindingsTest.js --- tests/js/dbBindingsTest.js | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index ac8a36ce..94e07067 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -481,9 +481,39 @@ test('dbInsertWallLossesSurface', function (t) { t.equal(res[size].surface, obj2.surface, res[size].surface + " != " + obj2.surface); t.equal(res[size].conditionFactor, obj2.conditionFactor, res[size].conditionFactor + " != " + obj2.conditionFactor); }); +/* +test('dbSelectPumpData', function (t) { + t.plan(2); + bindings.startup(); + t.type(bindings.selectPumpById, 'function'); -// PUMP TEST HERE + var res = bindings.selectPumpById(1); + var obj = { + id: 1, manufacturer: "manufacturer", model: "model", type: "type", serialNumber: "serialNumber", + status: "status", pumpType: "pumpType", radialBearingType: "radialBearingType", thrustBearingType: "thrustBearingType", + shaftOrientation: "shaftOrientation", shaftSealType: "shaftSealType", fluidType: "fluidType", priority: "priority", + driveType: "driveType", flangeConnectionClass: "flangeConnectionClass", flangeConnectionSize: "flangeConnectionSize", + numShafts: 1, speed: 2, numStages: 1, yearlyOperatingHours: 9000, yearInstalled: 2018, + finalMotorRpm: 1780, inletDiameter: 5, weight: 90, outletDiameter: 6, + percentageOfSchedule: 89, dailyPumpCapacity: 90, measuredPumpCapacity: 85, + pumpPerformance: 99, staticSuctionHead: 15, staticDischargeHead: 11, fluidDensity: 13, + lengthOfDischargePipe: 14, pipeDesignFrictionLosses: 0.5, maxWorkingPressure: 250, + maxAmbientTemperature: 85, maxSuctionLift: 1.5, displacement: 600, startingTorque: 400, + ratedSpeed: 70, shaftDiameter: 15, impellerDiameter: 20, efficiency: 88, + output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 + }; + t.equal(res.id, obj.id, res.id + " != " + obj.id); + + // bindings.insertPump(pump_example); + //var all_pumps = bindings.selectPumps(); + //var size = all_pumps.size; + // t.equal(all_pumps.length, 1); + + // var all_motors = bindings.selectMotors(); + //var test = 0 +}); +*/ test('dbDeletions', function (t) { t.plan(7); bindings.startup(); From 1971906ff7b27e54d1eb00f7ab5ead175497423a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 3 Feb 2020 13:50:48 -0500 Subject: [PATCH 022/217] Updated dbBindingsTest.js (Pump bindings not yet working properly) --- bindings/db.h | 5 ++++- include/sqlite/SQLite.h | 3 ++- tests/SQLite.unit.cpp | 6 ++++++ tests/js/dbBindingsTest.js | 11 +++++++---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index ae6bc948..7e506ccf 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -52,11 +52,13 @@ std::string GetStr(std::string const &nm) inline void SetObj(Local &obj, const std::string &key, double val) { Nan::Set(obj, Nan::New(key).ToLocalChecked(), Nan::New(val)); + //Nan::Set(obj, Nan::New(static_cast(key)).ToLocalChecked(), Nan::New(val)); } inline void SetObj(Local &obj, const std::string &key, const std::string &val) { Nan::Set(obj, Nan::New(key).ToLocalChecked(), Nan::New(val).ToLocalChecked()); + //Nan::Set(obj, Nan::New(static_cast(key)).ToLocalChecked(), Nan::New(val).ToLocalChecked()); } void SetPumpData(Local & obj, const PumpData & pump) { @@ -780,7 +782,8 @@ NAN_METHOD(selectPumpById) { Local pump = Nan::New(); try { //SetPumpData(pump, sql->getPumpDataById(static_cast(info[0].FromJust()))); - SetPumpData(pump, sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust()))); + //SetPumpData(pump, sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust()))); + sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust())); } catch (std::runtime_error const & e) { std::string const what = e.what(); ThrowError(std::string("std::runtime_error thrown in selectPumpById - db.h: " + what).c_str()); diff --git a/include/sqlite/SQLite.h b/include/sqlite/SQLite.h index 7f9f2487..3aca8d28 100644 --- a/include/sqlite/SQLite.h +++ b/include/sqlite/SQLite.h @@ -82,7 +82,8 @@ class SQLiteWrapper return retVal; } reset_command(stmt); - throw std::runtime_error("Invalid command during get_object"); + //throw std::runtime_error("Invalid command during get_object"); + throw std::runtime_error("Invalid command during get_object. SQLite return code: " + std::to_string(rc)); } throw std::runtime_error("No valid database connection"); } diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index dff79140..02cde7bf 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -1232,5 +1232,11 @@ TEST_CASE( "SQLite - Pump Data inserts and updates and selects", "[sqlite][pump] sqlite.updatePumpData(pump); compare(sqlite.getPumpData().back(), pump); + + auto pumpById = sqlite.getPumpDataById(2); + compare(sqlite.getPumpData().back(), pumpById); + + //sqlite.deletePumpData(2); + //compare(sqlite.getPumpData().back(), expected); } } diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 94e07067..1067d9af 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -481,13 +481,15 @@ test('dbInsertWallLossesSurface', function (t) { t.equal(res[size].surface, obj2.surface, res[size].surface + " != " + obj2.surface); t.equal(res[size].conditionFactor, obj2.conditionFactor, res[size].conditionFactor + " != " + obj2.conditionFactor); }); -/* +///* test('dbSelectPumpData', function (t) { t.plan(2); bindings.startup(); t.type(bindings.selectPumpById, 'function'); - var res = bindings.selectPumpById(1); + //var res = bindings.selectPumpById(1); + var test = bindings.selectPumps(); + var size = test.length; var obj = { id: 1, manufacturer: "manufacturer", model: "model", type: "type", serialNumber: "serialNumber", status: "status", pumpType: "pumpType", radialBearingType: "radialBearingType", thrustBearingType: "thrustBearingType", @@ -503,7 +505,8 @@ test('dbSelectPumpData', function (t) { output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 }; - t.equal(res.id, obj.id, res.id + " != " + obj.id); + //t.equal(res.id, obj.id, res.id + " != " + obj.id); + t.equal(size, 0, size + " != 0"); // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); @@ -513,7 +516,7 @@ test('dbSelectPumpData', function (t) { // var all_motors = bindings.selectMotors(); //var test = 0 }); -*/ +//*/ test('dbDeletions', function (t) { t.plan(7); bindings.startup(); From 8975dbdef0efde90907cfaecd50baead3c184cce Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 3 Feb 2020 16:22:54 -0500 Subject: [PATCH 023/217] Continuing to debug Pump table bindings --- Dockerfile | 4 ++++ bindings/db.h | 17 +++++++++++++++++ src/sqlite/SQLite.cpp | 10 ++++++++++ tests/SQLite.unit.cpp | 3 ++- tests/js/dbBindingsTest.js | 9 ++++++--- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 31d1728a..6ec75bff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,6 +118,10 @@ WORKDIR /home/ RUN apt-get -y install emacs RUN emacs --version +# Install sqlite3 +RUN apt-get install sqlite3 libsqlite3-dev +RUN sqlite3 --version + # Commands to run for building/testing/running AMO-Tools-Suite # ------------------------------------------------------------- diff --git a/bindings/db.h b/bindings/db.h index 7e506ccf..81b2b352 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -15,6 +15,7 @@ #include #include #include +//#include using namespace Nan; using namespace v8; @@ -125,8 +126,24 @@ NAN_METHOD(startup) // sql = std::unique_ptr(new SQLite(dbName, ! fileExists)); std::string const dbName = ":memory:"; + //std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); + auto sqlite = SQLite("test.db", true); + /* + PumpData pump("manufacturer", "model", "type", "serialNumber", "status", "pumpType", "radialBearingType", + "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", + "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, + 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1); + auto flag = sql->insertPumpData(pump); + //std::ofstream ofs("debug.txt"); + //auto test = sql->getPumpData(); + //ofs << std::endl; + //ofs << "getPumpData() returned a size of " << test.size(); + //ofs << std::endl; + //ofs << "manufacturer: " << test[0].getManufacturer(); + //ofs << std::endl; + */ } NAN_METHOD(selectSolidLoadChargeMaterials) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index fb1bb7ae..38aa0e9d 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1245,6 +1245,16 @@ void SQLite::insert_default_data() //std::cout << "TEST"; } + /* + std::ofstream ofs("debug.txt"); + auto test = getPumpData(); + ofs << std::endl; + ofs << "get_default_pump_data() returned a size of " << test.size(); + ofs << std::endl; + ofs << "manufacturer: " << test[0].getManufacturer(); + ofs << std::endl; + */ + //*/ //std::ofstream ofs("debug.txt"); /* diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index 02cde7bf..c7b7245b 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -1202,7 +1202,8 @@ TEST_CASE( "SQLite - Pump Data inserts and updates and selects", "[sqlite][pump] }; auto sqlite = SQLite(":memory:", true); -// auto sqlite = SQLite("cpp_amo_tools_suite.db", true); + //auto sqlite = SQLite("cpp_amo_tools_suite.db", true); + //auto sqlite = SQLite("test.db", true); { auto const pumps = sqlite.getPumpData(); diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 1067d9af..97dcb319 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -488,8 +488,8 @@ test('dbSelectPumpData', function (t) { t.type(bindings.selectPumpById, 'function'); //var res = bindings.selectPumpById(1); - var test = bindings.selectPumps(); - var size = test.length; + //var test = bindings.selectPumps(); + //var size = test.length; var obj = { id: 1, manufacturer: "manufacturer", model: "model", type: "type", serialNumber: "serialNumber", status: "status", pumpType: "pumpType", radialBearingType: "radialBearingType", thrustBearingType: "thrustBearingType", @@ -505,8 +505,11 @@ test('dbSelectPumpData', function (t) { output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 }; + //bindings.insertPump(obj); + var test = bindings.selectPumps(); + //t.equal(res.id, obj.id, res.id + " != " + obj.id); - t.equal(size, 0, size + " != 0"); + t.equal(test.length, 0, test.length + " != 1"); // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); From d50aa27e76bdb9d1b6c12071ae1302bf884202eb Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 10:44:32 -0500 Subject: [PATCH 024/217] Added temporary debugging code to find problem with Pump default data --- bindings/db.h | 17 +++++------------ src/sqlite/SQLite.cpp | 6 +++++- tests/js/dbBindingsTest.js | 3 ++- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index 81b2b352..8f4f197e 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -15,7 +15,6 @@ #include #include #include -//#include using namespace Nan; using namespace v8; @@ -125,24 +124,18 @@ NAN_METHOD(startup) // sql.reset(); // sql = std::unique_ptr(new SQLite(dbName, ! fileExists)); - std::string const dbName = ":memory:"; - //std::string const dbName = "test.db"; + //std::string const dbName = ":memory:"; + std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); - auto sqlite = SQLite("test.db", true); + + //auto sqlite = SQLite("test.db", true); /* PumpData pump("manufacturer", "model", "type", "serialNumber", "status", "pumpType", "radialBearingType", "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1); - auto flag = sql->insertPumpData(pump); - //std::ofstream ofs("debug.txt"); - //auto test = sql->getPumpData(); - //ofs << std::endl; - //ofs << "getPumpData() returned a size of " << test.size(); - //ofs << std::endl; - //ofs << "manufacturer: " << test[0].getManufacturer(); - //ofs << std::endl; + sql->insertPumpData(pump); */ } diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 38aa0e9d..eefb7ea9 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1238,13 +1238,17 @@ void SQLite::insert_default_data() //getWallLossesSurfaceById(1); } ///* + std::ofstream fout; + fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { - insert_pump_data(pump); + bool flag = insert_pump_data(pump); + fout << flag << std::endl; // expected number of times 'SUCCESS' printed to file: 35 //auto testing = getPumpDataById(1); //auto hello = 0; //std::cout << "TEST"; } + fout.close(); /* std::ofstream ofs("debug.txt"); auto test = getPumpData(); diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 97dcb319..cfc83807 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -509,7 +509,8 @@ test('dbSelectPumpData', function (t) { var test = bindings.selectPumps(); //t.equal(res.id, obj.id, res.id + " != " + obj.id); - t.equal(test.length, 0, test.length + " != 1"); + //t.equal(test.length, 0, test.length + " != 1"); + t.equal(0, 0, "0 != 0"); // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); From 8c294e65d082dd087f88962b411c592619daeddf Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 10:54:47 -0500 Subject: [PATCH 025/217] Updated dbSelectPumpData test in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index cfc83807..cf8c8da6 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -509,8 +509,8 @@ test('dbSelectPumpData', function (t) { var test = bindings.selectPumps(); //t.equal(res.id, obj.id, res.id + " != " + obj.id); - //t.equal(test.length, 0, test.length + " != 1"); - t.equal(0, 0, "0 != 0"); + t.equal(test.length, 1, test.length + " != 1"); + //t.equal(0, 0, "0 != 0"); // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); From 0d99939a451de5abb7fbb645d47ff21d43f548b8 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 11:02:03 -0500 Subject: [PATCH 026/217] Updated dbBindingsTest.js --- tests/js/dbBindingsTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index cf8c8da6..c3c60eb7 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -487,7 +487,7 @@ test('dbSelectPumpData', function (t) { bindings.startup(); t.type(bindings.selectPumpById, 'function'); - //var res = bindings.selectPumpById(1); + var res = bindings.selectPumpById(1); //var test = bindings.selectPumps(); //var size = test.length; var obj = { From 3a22b74cc7fba88df3105bd1f4210b4574e88d7b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 11:35:24 -0500 Subject: [PATCH 027/217] Pump table now being correctly populated in bindings --- bindings/db.h | 4 ++-- tests/js/dbBindingsTest.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index 8f4f197e..b592ee2f 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -792,8 +792,8 @@ NAN_METHOD(selectPumpById) { Local pump = Nan::New(); try { //SetPumpData(pump, sql->getPumpDataById(static_cast(info[0].FromJust()))); - //SetPumpData(pump, sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust()))); - sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust())); + SetPumpData(pump, sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust()))); + //sql->getPumpDataById(static_cast(Nan::To(info[0]).FromJust())); } catch (std::runtime_error const & e) { std::string const what = e.what(); ThrowError(std::string("std::runtime_error thrown in selectPumpById - db.h: " + what).c_str()); diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index c3c60eb7..3c15803d 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -488,8 +488,7 @@ test('dbSelectPumpData', function (t) { t.type(bindings.selectPumpById, 'function'); var res = bindings.selectPumpById(1); - //var test = bindings.selectPumps(); - //var size = test.length; + var obj = { id: 1, manufacturer: "manufacturer", model: "model", type: "type", serialNumber: "serialNumber", status: "status", pumpType: "pumpType", radialBearingType: "radialBearingType", thrustBearingType: "thrustBearingType", @@ -506,10 +505,11 @@ test('dbSelectPumpData', function (t) { }; //bindings.insertPump(obj); - var test = bindings.selectPumps(); + //var test = bindings.selectPumps(); - //t.equal(res.id, obj.id, res.id + " != " + obj.id); - t.equal(test.length, 1, test.length + " != 1"); + t.equal(res.id, obj.id, res.id + " != " + obj.id); + //t.equal(res.manufacturer , obj.manufacturer, res.manufacturer + " != " + obj.manufacturer); + //t.equal(test.length, 1, test.length + " != 1"); //t.equal(0, 0, "0 != 0"); // bindings.insertPump(pump_example); From 7dfdcf32d236171a619c698a7453e2c712a4a2b6 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 12:04:21 -0500 Subject: [PATCH 028/217] Switched back to in-memory database for bindings tests --- bindings/db.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index b592ee2f..4cdd2261 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -124,8 +124,8 @@ NAN_METHOD(startup) // sql.reset(); // sql = std::unique_ptr(new SQLite(dbName, ! fileExists)); - //std::string const dbName = ":memory:"; - std::string const dbName = "test.db"; + std::string const dbName = ":memory:"; + //std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); From 3f2945c87250e734c3d7c95dbe58b908f14e6430 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 12:24:27 -0500 Subject: [PATCH 029/217] In SQLite.cpp, works with output debug file, doesn't work without it --- src/sqlite/SQLite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index eefb7ea9..9962bd79 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1242,7 +1242,7 @@ void SQLite::insert_default_data() fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { bool flag = insert_pump_data(pump); - fout << flag << std::endl; // expected number of times 'SUCCESS' printed to file: 35 + fout << flag << std::endl; // expected number of times flag printed to file: 35 //auto testing = getPumpDataById(1); //auto hello = 0; //std::cout << "TEST"; From abb8b2509c042afc4890b882c8c43a4ee8b56d98 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 13:23:15 -0500 Subject: [PATCH 030/217] Pump table bindings work with std::ofstream variable declared, don't work without --- src/sqlite/SQLite.cpp | 56 ++++--------------------------------------- 1 file changed, 4 insertions(+), 52 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 9962bd79..0475febc 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1237,65 +1237,17 @@ void SQLite::insert_default_data() insert_wall_losses_surface(surface); //getWallLossesSurfaceById(1); } - ///* std::ofstream fout; - fout.open("debug.txt", std::ios::app); + //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { - bool flag = insert_pump_data(pump); - fout << flag << std::endl; // expected number of times flag printed to file: 35 + insert_pump_data(pump); + //fout << flag << std::endl; // expected number of times flag printed to file: 35 //auto testing = getPumpDataById(1); //auto hello = 0; //std::cout << "TEST"; } - fout.close(); - /* - std::ofstream ofs("debug.txt"); - auto test = getPumpData(); - ofs << std::endl; - ofs << "get_default_pump_data() returned a size of " << test.size(); - ofs << std::endl; - ofs << "manufacturer: " << test[0].getManufacturer(); - ofs << std::endl; - */ - - //*/ - //std::ofstream ofs("debug.txt"); - /* - auto test = get_default_pump_data(); - - //std::ofstream ofs("debug.txt"); - ofs << "get_default_pump_data() returned a size of " << test.size(); - auto index = 0; - for( auto const & pump : get_default_pump_data() ) { - ofs << " pump: " << pump.manufacturer << " pump.id (uninitialized prob): " << pump.id << std::endl; - auto result = insert_pump_data(pump); - ofs << " result: " << result << std::endl; - auto all_pumps_so_far = getPumpData(); - ofs << "pump count as of now: " << all_pumps_so_far.size() << std::endl << std::endl; - for( auto const & pump_inner : all_pumps_so_far ) { - ofs << " pump_inner: " << pump_inner.manufacturer << " pump_inner.id (should be initialized): " << pump_inner.id << std::endl; - } - ofs << std::endl << std::endl; - } - auto hello = 0; - */ - - /* - //SolidLoadChargeMaterial slcm("Substance", 0.247910198231111, 887, 0.2501, 1117); - //auto result = insert_solid_load_charge_materials(slcm); - //ofs << "result: " << result << std::endl; - //auto slcm_data = get_default_solid_load_charge_materials(); - auto slcm_data = getSolidLoadChargeMaterials(); - //auto slcm_data_single = getSolidLoadChargeMaterialById(0); - ofs << "getSolidLoadChargeMaterials() returned a size of " << slcm_data.size(); - ofs << std::endl << std::endl; - for( auto const & slcm : slcm_data ) { - ofs << " slcm: " << slcm.substance << " slcm.id: " << slcm.id << std::endl; - } - //ofs << "getSolidLoadChargeMaterialById(0) returned substance of " << slcm_data_single.substance << std::endl; - */ - + //fout.close(); } bool SQLite::insert_solid_load_charge_materials(SolidLoadChargeMaterial const & material) From 0ae26b654c7758b711713672688bbe01b6b317b0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 14:09:29 -0500 Subject: [PATCH 031/217] Changed ordering of function calls in insert_default_data() in SQLite.cpp --- src/sqlite/SQLite.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 0475febc..b9542d39 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1215,6 +1215,9 @@ void SQLite::create_tables() void SQLite::insert_default_data() { + for( auto const & pump : get_default_pump_data() ) { + insert_pump_data(pump); + } for( auto const & material : get_default_solid_load_charge_materials() ) { insert_solid_load_charge_materials(material); } @@ -1235,8 +1238,8 @@ void SQLite::insert_default_data() } for( auto const & surface : get_default_wall_losses_surface() ) { insert_wall_losses_surface(surface); - //getWallLossesSurfaceById(1); } + /* std::ofstream fout; //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { @@ -1248,6 +1251,7 @@ void SQLite::insert_default_data() } //fout.close(); + */ } bool SQLite::insert_solid_load_charge_materials(SolidLoadChargeMaterial const & material) From 890145b71c2cddf01249230f3090ddd26530e295 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 14:25:28 -0500 Subject: [PATCH 032/217] Pump table bindings appear to be working now --- src/sqlite/SQLite.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index b9542d39..9545e8dd 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1244,13 +1244,7 @@ void SQLite::insert_default_data() //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); - //fout << flag << std::endl; // expected number of times flag printed to file: 35 - //auto testing = getPumpDataById(1); - //auto hello = 0; - //std::cout << "TEST"; - } - //fout.close(); */ } From a9932ab876aae1abfb3d22077800e64b828fb45d Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 15:45:55 -0500 Subject: [PATCH 033/217] Added dbSelectPumpData unit test to dbBindingsTest.js --- tests/js/dbBindingsTest.js | 55 +++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 3c15803d..c270fcff 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -483,7 +483,7 @@ test('dbInsertWallLossesSurface', function (t) { }); ///* test('dbSelectPumpData', function (t) { - t.plan(2); + t.plan(48); //2 bindings.startup(); t.type(bindings.selectPumpById, 'function'); @@ -504,13 +504,54 @@ test('dbSelectPumpData', function (t) { output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 }; - //bindings.insertPump(obj); - //var test = bindings.selectPumps(); - + //t.equal(res, obj, res.toString() + " != " + obj.toString()); t.equal(res.id, obj.id, res.id + " != " + obj.id); - //t.equal(res.manufacturer , obj.manufacturer, res.manufacturer + " != " + obj.manufacturer); - //t.equal(test.length, 1, test.length + " != 1"); - //t.equal(0, 0, "0 != 0"); + t.equal(res.manufacturer, obj.manufacturer, res.manufacturer + " != " + obj.manufacturer); + t.equal(res.model, obj.model, res.model + " != " + obj.model); + t.equal(res.type, obj.type, res.type + " != " + obj.type); + t.equal(res.serialNumber, obj.serialNumber, res.serialNumber + " != " + obj.serialNumber); + t.equal(res.status, obj.status, res.status + " != " + obj.status); + t.equal(res.pumpType, obj.pumpType, res.pumpType + " != " + obj.pumpType); + t.equal(res.radialBearingType, obj.radialBearingType, res.radialBearingType + " != " + obj.radialBearingType); + t.equal(res.thrustBearingType, obj.thrustBearingType, res.thrustBearingType + " != " + obj.thrustBearingType); + t.equal(res.shaftOrientation, obj.shaftOrientation, res.shaftOrientation + " != " + obj.shaftOrientation); + t.equal(res.shaftSealType, obj.shaftSealType, res.shaftSealType + " != " + obj.shaftSealType); + t.equal(res.fluidType, obj.fluidType, res.fluidType + " != " + obj.fluidType); + t.equal(res.priority, obj.priority, res.priority + " != " + obj.priority); + t.equal(res.driveType, obj.driveType, res.driveType + " != " + obj.driveType); + t.equal(res.flangeConnectionClass, obj.flangeConnectionClass, res.flangeConnectionClass + " != " + obj.flangeConnectionClass); + t.equal(res.flangeConnectionSize, obj.flangeConnectionSize, res.flangeConnectionSize + " != " + obj.flangeConnectionSize); + t.equal(res.numShafts, obj.numShafts, res.numShafts + " != " + obj.numShafts); + t.equal(res.speed, obj.speed, res.speed + " != " + obj.speed); + t.equal(res.numStages, obj.numStages, res.numStages + " != " + obj.numStages); + t.equal(res.yearlyOperatingHours, obj.yearlyOperatingHours, res.yearlyOperatingHours + " != " + obj.yearlyOperatingHours); + t.equal(res.yearlyInstalled, obj.yearlyInstalled, res.yearlyInstalled + " != " + obj.yearlyInstalled); + t.equal(res.finalMotorRpm, obj.finalMotorRpm, res.finalMotorRpm + " != " + obj.finalMotorRpm); + t.equal(res.inletDiameter, obj.inletDiameter, res.inletDiameter + " != " + obj.inletDiameter); + t.equal(res.weight, obj.weight, res.weight + " != " + obj.weight); + t.equal(res.outletDiameter, obj.outletDiameter, res.outletDiameter + " != " + obj.outletDiameter); + t.equal(res.percentageOfSchedule, obj.percentageOfSchedule, res.percentageOfSchedule + " != " + obj.percentageOfSchedule); + t.equal(res.dailyPumpCapacity, obj.dailyPumpCapacity, res.dailyPumpCapacity + " != " + obj.dailyPumpCapacity); + t.equal(res.measuredPumpCapacity, obj.measuredPumpCapacity, res.measuredPumpCapacity + " != " + obj.measuredPumpCapacity); + t.equal(res.pumpPerformance, obj.pumpPerformance, res.pumpPerformance + " != " + obj.pumpPerformance); + t.equal(res.staticSuctionHead, obj.staticSuctionHead, res.staticSuctionHead + " != " + obj.staticSuctionHead); + t.equal(res.staticDischargeHead, obj.staticDischargeHead, res.staticDischargeHead + " != " + obj.staticDischargeHead); + t.equal(res.fluidDensity, obj.fluidDensity, res.fluidDensity + " != " + obj.fluidDensity); + t.equal(res.lengthOfDischargePipe, obj.lengthOfDischargePipe, res.lengthOfDischargePipe + " != " + obj.lengthOfDischargePipe); + t.equal(res.pipeDesignFrictionLosses, obj.pipeDesignFrictionLosses, res.pipeDesignFrictionLosses + " != " + obj.pipeDesignFrictionLosses); + t.equal(res.maxWorkingPressure, obj.maxWorkingPressure, res.maxWorkingPressure + " != " + obj.maxWorkingPressure); + t.equal(res.maxAmbientTemperature, obj.maxAmbientTemperature, res.maxAmbientTemperature + " != " + obj.maxAmbientTemperature); + t.equal(res.maxSuctionLift, obj.maxSuctionLift, res.maxSuctionLift + " != " + obj.maxSuctionLift); + t.equal(res.displacement, obj.displacement, res.displacement + " != " + obj.displacement); + t.equal(res.startingTorque, obj.startingTorque, res.startingTorque + " != " + obj.startingTorque); + t.equal(res.ratedSpeed, obj.ratedSpeed, res.ratedSpeed + " != " + obj.ratedSpeed); + t.equal(res.shaftDiameter, obj.shaftDiameter, res.shaftDiameter + " != " + obj.shaftDiameter); + t.equal(res.impellerDiameter, obj.impellerDiameter, res.impellerDiameter + " != " + obj.impellerDiameter); + t.equal(res.efficiency, obj.efficiency, res.efficiency + " != " + obj.efficiency); + t.equal(res.output60Hz, obj.output60Hz, res.output60Hz + " != " + obj.output60Hz); + t.equal(res.minFlowSize, obj.minFlowSize, res.minFlowSize + " != " + obj.minFlowSize); + t.equal(res.pumpSize, obj.pumpSize, res.pumpSize + " != " + obj.pumpSize); + t.equal(res.outOfService, obj.outOfService, res.outOfService + " != " + obj.outOfService); // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); From e42a1a8ff386faf5de7b06b1c1679580d1c9cd16 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 16:03:55 -0500 Subject: [PATCH 034/217] Added unit test for bindings.selectPumps --- tests/js/dbBindingsTest.js | 57 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index c270fcff..02fb19b4 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -483,10 +483,10 @@ test('dbInsertWallLossesSurface', function (t) { }); ///* test('dbSelectPumpData', function (t) { - t.plan(48); //2 + t.plan(97); //2 bindings.startup(); - t.type(bindings.selectPumpById, 'function'); + t.type(bindings.selectPumpById, 'function'); var res = bindings.selectPumpById(1); var obj = { @@ -553,6 +553,59 @@ test('dbSelectPumpData', function (t) { t.equal(res.pumpSize, obj.pumpSize, res.pumpSize + " != " + obj.pumpSize); t.equal(res.outOfService, obj.outOfService, res.outOfService + " != " + obj.outOfService); + + t.type(bindings.selectPumps, 'function'); + res = bindings.selectPumps(); + + t.equal(res.length, 1, "array is not of size 1"); + t.equal(res[0].id, obj.id, res[0].id + " != " + obj.id); + t.equal(res[0].manufacturer, obj.manufacturer, res[0].manufacturer + " != " + obj.manufacturer); + t.equal(res[0].model, obj.model, res[0].model + " != " + obj.model); + t.equal(res[0].type, obj.type, res[0].type + " != " + obj.type); + t.equal(res[0].serialNumber, obj.serialNumber, res[0].serialNumber + " != " + obj.serialNumber); + t.equal(res[0].status, obj.status, res[0].status + " != " + obj.status); + t.equal(res[0].pumpType, obj.pumpType, res[0].pumpType + " != " + obj.pumpType); + t.equal(res[0].radialBearingType, obj.radialBearingType, res[0].radialBearingType + " != " + obj.radialBearingType); + t.equal(res[0].thrustBearingType, obj.thrustBearingType, res[0].thrustBearingType + " != " + obj.thrustBearingType); + t.equal(res[0].shaftOrientation, obj.shaftOrientation, res[0].shaftOrientation + " != " + obj.shaftOrientation); + t.equal(res[0].shaftSealType, obj.shaftSealType, res[0].shaftSealType + " != " + obj.shaftSealType); + t.equal(res[0].fluidType, obj.fluidType, res[0].fluidType + " != " + obj.fluidType); + t.equal(res[0].priority, obj.priority, res[0].priority + " != " + obj.priority); + t.equal(res[0].driveType, obj.driveType, res[0].driveType + " != " + obj.driveType); + t.equal(res[0].flangeConnectionClass, obj.flangeConnectionClass, res[0].flangeConnectionClass + " != " + obj.flangeConnectionClass); + t.equal(res[0].flangeConnectionSize, obj.flangeConnectionSize, res[0].flangeConnectionSize + " != " + obj.flangeConnectionSize); + t.equal(res[0].numShafts, obj.numShafts, res[0].numShafts + " != " + obj.numShafts); + t.equal(res[0].speed, obj.speed, res[0].speed + " != " + obj.speed); + t.equal(res[0].numStages, obj.numStages, res[0].numStages + " != " + obj.numStages); + t.equal(res[0].yearlyOperatingHours, obj.yearlyOperatingHours, res[0].yearlyOperatingHours + " != " + obj.yearlyOperatingHours); + t.equal(res[0].yearlyInstalled, obj.yearlyInstalled, res[0].yearlyInstalled + " != " + obj.yearlyInstalled); + t.equal(res[0].finalMotorRpm, obj.finalMotorRpm, res[0].finalMotorRpm + " != " + obj.finalMotorRpm); + t.equal(res[0].inletDiameter, obj.inletDiameter, res[0].inletDiameter + " != " + obj.inletDiameter); + t.equal(res[0].weight, obj.weight, res[0].weight + " != " + obj.weight); + t.equal(res[0].outletDiameter, obj.outletDiameter, res[0].outletDiameter + " != " + obj.outletDiameter); + t.equal(res[0].percentageOfSchedule, obj.percentageOfSchedule, res[0].percentageOfSchedule + " != " + obj.percentageOfSchedule); + t.equal(res[0].dailyPumpCapacity, obj.dailyPumpCapacity, res[0].dailyPumpCapacity + " != " + obj.dailyPumpCapacity); + t.equal(res[0].measuredPumpCapacity, obj.measuredPumpCapacity, res[0].measuredPumpCapacity + " != " + obj.measuredPumpCapacity); + t.equal(res[0].pumpPerformance, obj.pumpPerformance, res[0].pumpPerformance + " != " + obj.pumpPerformance); + t.equal(res[0].staticSuctionHead, obj.staticSuctionHead, res[0].staticSuctionHead + " != " + obj.staticSuctionHead); + t.equal(res[0].staticDischargeHead, obj.staticDischargeHead, res[0].staticDischargeHead + " != " + obj.staticDischargeHead); + t.equal(res[0].fluidDensity, obj.fluidDensity, res[0].fluidDensity + " != " + obj.fluidDensity); + t.equal(res[0].lengthOfDischargePipe, obj.lengthOfDischargePipe, res[0].lengthOfDischargePipe + " != " + obj.lengthOfDischargePipe); + t.equal(res[0].pipeDesignFrictionLosses, obj.pipeDesignFrictionLosses, res[0].pipeDesignFrictionLosses + " != " + obj.pipeDesignFrictionLosses); + t.equal(res[0].maxWorkingPressure, obj.maxWorkingPressure, res[0].maxWorkingPressure + " != " + obj.maxWorkingPressure); + t.equal(res[0].maxAmbientTemperature, obj.maxAmbientTemperature, res[0].maxAmbientTemperature + " != " + obj.maxAmbientTemperature); + t.equal(res[0].maxSuctionLift, obj.maxSuctionLift, res[0].maxSuctionLift + " != " + obj.maxSuctionLift); + t.equal(res[0].displacement, obj.displacement, res[0].displacement + " != " + obj.displacement); + t.equal(res[0].startingTorque, obj.startingTorque, res[0].startingTorque + " != " + obj.startingTorque); + t.equal(res[0].ratedSpeed, obj.ratedSpeed, res[0].ratedSpeed + " != " + obj.ratedSpeed); + t.equal(res[0].shaftDiameter, obj.shaftDiameter, res[0].shaftDiameter + " != " + obj.shaftDiameter); + t.equal(res[0].impellerDiameter, obj.impellerDiameter, res[0].impellerDiameter + " != " + obj.impellerDiameter); + t.equal(res[0].efficiency, obj.efficiency, res[0].efficiency + " != " + obj.efficiency); + t.equal(res[0].output60Hz, obj.output60Hz, res[0].output60Hz + " != " + obj.output60Hz); + t.equal(res[0].minFlowSize, obj.minFlowSize, res[0].minFlowSize + " != " + obj.minFlowSize); + t.equal(res[0].pumpSize, obj.pumpSize, res[0].pumpSize + " != " + obj.pumpSize); + t.equal(res[0].outOfService, obj.outOfService, res[0].outOfService + " != " + obj.outOfService); + // bindings.insertPump(pump_example); //var all_pumps = bindings.selectPumps(); //var size = all_pumps.size; From a84ca3cd1de5b45aa48a5c87d2acbc578d31c717 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 4 Feb 2020 16:31:07 -0500 Subject: [PATCH 035/217] Added unit test dbInsertPump to dbBindingsTest.js --- tests/js/dbBindingsTest.js | 85 ++++++++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 7 deletions(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 02fb19b4..4dc7d8d7 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -481,7 +481,7 @@ test('dbInsertWallLossesSurface', function (t) { t.equal(res[size].surface, obj2.surface, res[size].surface + " != " + obj2.surface); t.equal(res[size].conditionFactor, obj2.conditionFactor, res[size].conditionFactor + " != " + obj2.conditionFactor); }); -///* + test('dbSelectPumpData', function (t) { t.plan(97); //2 bindings.startup(); @@ -606,15 +606,86 @@ test('dbSelectPumpData', function (t) { t.equal(res[0].pumpSize, obj.pumpSize, res[0].pumpSize + " != " + obj.pumpSize); t.equal(res[0].outOfService, obj.outOfService, res[0].outOfService + " != " + obj.outOfService); - // bindings.insertPump(pump_example); - //var all_pumps = bindings.selectPumps(); - //var size = all_pumps.size; - // t.equal(all_pumps.length, 1); - // var all_motors = bindings.selectMotors(); //var test = 0 }); -//*/ + +test('dbInsertPump', function (t) { + t.plan(49); + bindings.startup(); + + t.type(bindings.insertPump, 'function'); + + var obj = { + id: 2, manufacturer: "manufacturer2", model: "model2", type: "type2", serialNumber: "serialNumber2", + status: "status2", pumpType: "pumpType2", radialBearingType: "radialBearingType2", thrustBearingType: "thrustBearingType2", + shaftOrientation: "shaftOrientation2", shaftSealType: "shaftSealType2", fluidType: "fluidType2", priority: "priority2", + driveType: "driveType2", flangeConnectionClass: "flangeConnectionClass2", flangeConnectionSize: "flangeConnectionSize2", + numShafts: 1, speed: 2, numStages: 1, yearlyOperatingHours: 9000, yearInstalled: 2018, + finalMotorRpm: 1780, inletDiameter: 5, weight: 90, outletDiameter: 6, + percentageOfSchedule: 89, dailyPumpCapacity: 90, measuredPumpCapacity: 85, + pumpPerformance: 99, staticSuctionHead: 15, staticDischargeHead: 11, fluidDensity: 13, + lengthOfDischargePipe: 14, pipeDesignFrictionLosses: 0.5, maxWorkingPressure: 250, + maxAmbientTemperature: 85, maxSuctionLift: 1.5, displacement: 600, startingTorque: 400, + ratedSpeed: 70, shaftDiameter: 15, impellerDiameter: 20, efficiency: 88, + output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 + }; + + var res = bindings.selectPumps(); + var size = res.length; + bindings.insertPump(obj); + res = bindings.selectPumps(); + + t.equal(res.length, size + 1, res.length + " != " + (size + 1)); + t.equal(res[size].id, obj.id, res[size].id + " != " + obj.id); + t.equal(res[size].manufacturer, obj.manufacturer, res[size].manufacturer + " != " + obj.manufacturer); + t.equal(res[size].model, obj.model, res[size].model + " != " + obj.model); + t.equal(res[size].type, obj.type, res[size].type + " != " + obj.type); + t.equal(res[size].serialNumber, obj.serialNumber, res[size].serialNumber + " != " + obj.serialNumber); + t.equal(res[size].status, obj.status, res[size].status + " != " + obj.status); + t.equal(res[size].pumpType, obj.pumpType, res[size].pumpType + " != " + obj.pumpType); + t.equal(res[size].radialBearingType, obj.radialBearingType, res[size].radialBearingType + " != " + obj.radialBearingType); + t.equal(res[size].thrustBearingType, obj.thrustBearingType, res[size].thrustBearingType + " != " + obj.thrustBearingType); + t.equal(res[size].shaftOrientation, obj.shaftOrientation, res[size].shaftOrientation + " != " + obj.shaftOrientation); + t.equal(res[size].shaftSealType, obj.shaftSealType, res[size].shaftSealType + " != " + obj.shaftSealType); + t.equal(res[size].fluidType, obj.fluidType, res[size].fluidType + " != " + obj.fluidType); + t.equal(res[size].priority, obj.priority, res[size].priority + " != " + obj.priority); + t.equal(res[size].driveType, obj.driveType, res[size].driveType + " != " + obj.driveType); + t.equal(res[size].flangeConnectionClass, obj.flangeConnectionClass, res[size].flangeConnectionClass + " != " + obj.flangeConnectionClass); + t.equal(res[size].flangeConnectionSize, obj.flangeConnectionSize, res[size].flangeConnectionSize + " != " + obj.flangeConnectionSize); + t.equal(res[size].numShafts, obj.numShafts, res[size].numShafts + " != " + obj.numShafts); + t.equal(res[size].speed, obj.speed, res[size].speed + " != " + obj.speed); + t.equal(res[size].numStages, obj.numStages, res[size].numStages + " != " + obj.numStages); + t.equal(res[size].yearlyOperatingHours, obj.yearlyOperatingHours, res[size].yearlyOperatingHours + " != " + obj.yearlyOperatingHours); + t.equal(res[size].yearlyInstalled, obj.yearlyInstalled, res[size].yearlyInstalled + " != " + obj.yearlyInstalled); + t.equal(res[size].finalMotorRpm, obj.finalMotorRpm, res[size].finalMotorRpm + " != " + obj.finalMotorRpm); + t.equal(res[size].inletDiameter, obj.inletDiameter, res[size].inletDiameter + " != " + obj.inletDiameter); + t.equal(res[size].weight, obj.weight, res[size].weight + " != " + obj.weight); + t.equal(res[size].outletDiameter, obj.outletDiameter, res[size].outletDiameter + " != " + obj.outletDiameter); + t.equal(res[size].percentageOfSchedule, obj.percentageOfSchedule, res[size].percentageOfSchedule + " != " + obj.percentageOfSchedule); + t.equal(res[size].dailyPumpCapacity, obj.dailyPumpCapacity, res[size].dailyPumpCapacity + " != " + obj.dailyPumpCapacity); + t.equal(res[size].measuredPumpCapacity, obj.measuredPumpCapacity, res[size].measuredPumpCapacity + " != " + obj.measuredPumpCapacity); + t.equal(res[size].pumpPerformance, obj.pumpPerformance, res[size].pumpPerformance + " != " + obj.pumpPerformance); + t.equal(res[size].staticSuctionHead, obj.staticSuctionHead, res[size].staticSuctionHead + " != " + obj.staticSuctionHead); + t.equal(res[size].staticDischargeHead, obj.staticDischargeHead, res[size].staticDischargeHead + " != " + obj.staticDischargeHead); + t.equal(res[size].fluidDensity, obj.fluidDensity, res[size].fluidDensity + " != " + obj.fluidDensity); + t.equal(res[size].lengthOfDischargePipe, obj.lengthOfDischargePipe, res[size].lengthOfDischargePipe + " != " + obj.lengthOfDischargePipe); + t.equal(res[size].pipeDesignFrictionLosses, obj.pipeDesignFrictionLosses, res[size].pipeDesignFrictionLosses + " != " + obj.pipeDesignFrictionLosses); + t.equal(res[size].maxWorkingPressure, obj.maxWorkingPressure, res[size].maxWorkingPressure + " != " + obj.maxWorkingPressure); + t.equal(res[size].maxAmbientTemperature, obj.maxAmbientTemperature, res[size].maxAmbientTemperature + " != " + obj.maxAmbientTemperature); + t.equal(res[size].maxSuctionLift, obj.maxSuctionLift, res[size].maxSuctionLift + " != " + obj.maxSuctionLift); + t.equal(res[size].displacement, obj.displacement, res[size].displacement + " != " + obj.displacement); + t.equal(res[size].startingTorque, obj.startingTorque, res[size].startingTorque + " != " + obj.startingTorque); + t.equal(res[size].ratedSpeed, obj.ratedSpeed, res[size].ratedSpeed + " != " + obj.ratedSpeed); + t.equal(res[size].shaftDiameter, obj.shaftDiameter, res[size].shaftDiameter + " != " + obj.shaftDiameter); + t.equal(res[size].impellerDiameter, obj.impellerDiameter, res[size].impellerDiameter + " != " + obj.impellerDiameter); + t.equal(res[size].efficiency, obj.efficiency, res[size].efficiency + " != " + obj.efficiency); + t.equal(res[size].output6sizeHz, obj.output6sizeHz, res[size].output6sizeHz + " != " + obj.output6sizeHz); + t.equal(res[size].minFlowSize, obj.minFlowSize, res[size].minFlowSize + " != " + obj.minFlowSize); + t.equal(res[size].pumpSize, obj.pumpSize, res[size].pumpSize + " != " + obj.pumpSize); + t.equal(res[size].outOfService, obj.outOfService, res[size].outOfService + " != " + obj.outOfService); +}); + test('dbDeletions', function (t) { t.plan(7); bindings.startup(); From 6c294a71aadb3bae767f3462a7a8e30c932d12c7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 5 Feb 2020 10:03:12 -0500 Subject: [PATCH 036/217] Added unit tests for Pump update and delete in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 48 ++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 4dc7d8d7..a4e66cd6 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -605,9 +605,6 @@ test('dbSelectPumpData', function (t) { t.equal(res[0].minFlowSize, obj.minFlowSize, res[0].minFlowSize + " != " + obj.minFlowSize); t.equal(res[0].pumpSize, obj.pumpSize, res[0].pumpSize + " != " + obj.pumpSize); t.equal(res[0].outOfService, obj.outOfService, res[0].outOfService + " != " + obj.outOfService); - - // var all_motors = bindings.selectMotors(); - //var test = 0 }); test('dbInsertPump', function (t) { @@ -687,7 +684,7 @@ test('dbInsertPump', function (t) { }); test('dbDeletions', function (t) { - t.plan(7); + t.plan(8); bindings.startup(); var res = bindings.selectLiquidLoadChargeMaterials(); @@ -791,10 +788,31 @@ test('dbDeletions', function (t) { bindings.deleteWallLossesSurface(bindings.selectWallLossesSurface().length); res = bindings.selectWallLossesSurface(); t.equal(last, res[res.length - 1].surface); + + res = bindings.selectPumps(); + last = res[res.length - 1].id; + obj = { + id: 2, manufacturer: "manufacturer2", model: "model2", type: "type2", serialNumber: "serialNumber2", + status: "status2", pumpType: "pumpType2", radialBearingType: "radialBearingType2", thrustBearingType: "thrustBearingType2", + shaftOrientation: "shaftOrientation2", shaftSealType: "shaftSealType2", fluidType: "fluidType2", priority: "priority2", + driveType: "driveType2", flangeConnectionClass: "flangeConnectionClass2", flangeConnectionSize: "flangeConnectionSize2", + numShafts: 1, speed: 2, numStages: 1, yearlyOperatingHours: 9000, yearInstalled: 2018, + finalMotorRpm: 1780, inletDiameter: 5, weight: 90, outletDiameter: 6, + percentageOfSchedule: 89, dailyPumpCapacity: 90, measuredPumpCapacity: 85, + pumpPerformance: 99, staticSuctionHead: 15, staticDischargeHead: 11, fluidDensity: 13, + lengthOfDischargePipe: 14, pipeDesignFrictionLosses: 0.5, maxWorkingPressure: 250, + maxAmbientTemperature: 85, maxSuctionLift: 1.5, displacement: 600, startingTorque: 400, + ratedSpeed: 70, shaftDiameter: 15, impellerDiameter: 20, efficiency: 88, + output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 + }; + bindings.insertPump(obj); + bindings.deletePump(bindings.selectPumps().length); + res = bindings.selectPumps(); + t.equal(last, res[res.length - 1].id); }); test('dbUpdates', function (t) { - t.plan(7); + t.plan(8); bindings.startup(); var obj = { @@ -892,6 +910,26 @@ test('dbUpdates', function (t) { mat.surface = 'updated'; bindings.updateWallLossesSurface(mat); t.equal(bindings.selectWallLossesSurfaceById(bindings.selectWallLossesSurface().length).surface, 'updated'); + + obj = { + id: 2, manufacturer: "manufacturer2", model: "model2", type: "type2", serialNumber: "serialNumber2", + status: "status2", pumpType: "pumpType2", radialBearingType: "radialBearingType2", thrustBearingType: "thrustBearingType2", + shaftOrientation: "shaftOrientation2", shaftSealType: "shaftSealType2", fluidType: "fluidType2", priority: "priority2", + driveType: "driveType2", flangeConnectionClass: "flangeConnectionClass2", flangeConnectionSize: "flangeConnectionSize2", + numShafts: 1, speed: 2, numStages: 1, yearlyOperatingHours: 9000, yearInstalled: 2018, + finalMotorRpm: 1780, inletDiameter: 5, weight: 90, outletDiameter: 6, + percentageOfSchedule: 89, dailyPumpCapacity: 90, measuredPumpCapacity: 85, + pumpPerformance: 99, staticSuctionHead: 15, staticDischargeHead: 11, fluidDensity: 13, + lengthOfDischargePipe: 14, pipeDesignFrictionLosses: 0.5, maxWorkingPressure: 250, + maxAmbientTemperature: 85, maxSuctionLift: 1.5, displacement: 600, startingTorque: 400, + ratedSpeed: 70, shaftDiameter: 15, impellerDiameter: 20, efficiency: 88, + output60Hz: 15, minFlowSize: 15, pumpSize: 15, outOfService: 1 + }; + bindings.insertPump(obj); + pump = bindings.selectPumpById(bindings.selectPumps().length); + pump.manufacturer = 'updated'; + bindings.updatePump(pump); + t.equal(bindings.selectPumpById(bindings.selectPumps().length).manufacturer, 'updated'); }); From ebffc5ee91ede391d1761d9654df6b5a63060fd7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 5 Feb 2020 10:19:22 -0500 Subject: [PATCH 037/217] Pump Table fully implemented, unit tests created and passing --- CMakeLists.txt | 2 +- bindings/db.h | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0b671eb..9ad83ca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,7 +377,7 @@ set(INCLUDE_FILES include/sqlite/PumpData.h ) -# TODO: Add unit test for Pump Table +# Pending: PumpData calculator unit test set(TEST_FILES tests/OptimalSpecificSpeedCorrection.unit.cpp diff --git a/bindings/db.h b/bindings/db.h index 4cdd2261..c84dc434 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -128,15 +128,6 @@ NAN_METHOD(startup) //std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); - - //auto sqlite = SQLite("test.db", true); - /* - PumpData pump("manufacturer", "model", "type", "serialNumber", "status", "pumpType", "radialBearingType", - "thrustBearingType", "shaftOrientation", "shaftSealType", "fluidType", "priority", "driveType", - "flangeConnectionClass", "flangeConnectionSize", 1, 2, 1, 9000, 2018, 1780, 5, 90, 6, 89, 90, - 85, 99, 15, 11, 13, 14, 0.5, 250, 85, 1.5, 600, 400, 70, 15, 20, 88, 15, 15, 15, 1); - sql->insertPumpData(pump); - */ } NAN_METHOD(selectSolidLoadChargeMaterials) From 8d4143fe99a9ae9a13be38d66c8e0621287f1558 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 7 Feb 2020 13:09:52 -0500 Subject: [PATCH 038/217] Updated (Docker) commands.txt --- commands.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commands.txt b/commands.txt index adc3e13a..88b2d3d3 100644 --- a/commands.txt +++ b/commands.txt @@ -7,6 +7,14 @@ docker login docker push comma64/ornl:issue-258 + +docker stop $(docker ps -aq) 2>/dev/null || true +docker rm $(docker ps -a -q) 2>/dev/null|| true +docker rmi $(docker images -q) 2>/dev/null || true +docker image prune -fa || sudo systemctl restart docker +docker system prune -fa || sudo systemctl restart docker + + # Commands to run for building/testing/running AMO-Tools-Suite # ------------------------------------------------------------- From a190686cfe953d006166869b9d74008c8de433a9 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 7 Feb 2020 13:11:35 -0500 Subject: [PATCH 039/217] Updated plan count for dbSelectPumpData in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index a4e66cd6..0c1076c2 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -483,7 +483,7 @@ test('dbInsertWallLossesSurface', function (t) { }); test('dbSelectPumpData', function (t) { - t.plan(97); //2 + t.plan(99); //2, 97 bindings.startup(); t.type(bindings.selectPumpById, 'function'); From 85ceb22581b78d32098f03c629490c1b5bafbf56 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 7 Feb 2020 13:22:38 -0500 Subject: [PATCH 040/217] Updated plan count for dbSelectPumpData in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 0c1076c2..dd9ec5e0 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -483,7 +483,7 @@ test('dbInsertWallLossesSurface', function (t) { }); test('dbSelectPumpData', function (t) { - t.plan(99); //2, 97 + t.plan(98); //2, 97 bindings.startup(); t.type(bindings.selectPumpById, 'function'); From 503361fe4d2d2c18ac4c1032eb7502d09901befe Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 7 Feb 2020 13:38:39 -0500 Subject: [PATCH 041/217] Updated plan count for dbSelectPumpData in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index dd9ec5e0..a4e66cd6 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -483,7 +483,7 @@ test('dbInsertWallLossesSurface', function (t) { }); test('dbSelectPumpData', function (t) { - t.plan(98); //2, 97 + t.plan(97); //2 bindings.startup(); t.type(bindings.selectPumpById, 'function'); From 6a4e4516357338b9e683640c21076ca8ac58f0e3 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 7 Feb 2020 13:46:22 -0500 Subject: [PATCH 042/217] Added debugging code to SQLite.cpp --- src/sqlite/SQLite.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 9545e8dd..0a5775ca 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1215,9 +1215,11 @@ void SQLite::create_tables() void SQLite::insert_default_data() { + ///* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); } + //*/ for( auto const & material : get_default_solid_load_charge_materials() ) { insert_solid_load_charge_materials(material); } @@ -1240,6 +1242,11 @@ void SQLite::insert_default_data() insert_wall_losses_surface(surface); } /* + for( auto const & pump : get_default_pump_data() ) { + insert_pump_data(pump); + } + */ + /* std::ofstream fout; //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { From eba1b9647cfe0807535457fc85ef222686ddaa9a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 10 Feb 2020 08:58:37 -0500 Subject: [PATCH 043/217] Updated SQLite.cpp --- src/sqlite/SQLite.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 0a5775ca..a1c0ccf4 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1215,11 +1215,11 @@ void SQLite::create_tables() void SQLite::insert_default_data() { - ///* + /* for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); } - //*/ + */ for( auto const & material : get_default_solid_load_charge_materials() ) { insert_solid_load_charge_materials(material); } @@ -1246,13 +1246,15 @@ void SQLite::insert_default_data() insert_pump_data(pump); } */ - /* + ///* + // On Linux at least, if this ofstream variable is declared, pump table default data correctly populates. If it is not declared, the pump default + // data does not populate. Note that this is true only for the bindings. C++ unit tests work fine in any case. std::ofstream fout; //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { insert_pump_data(pump); } - */ + //*/ } bool SQLite::insert_solid_load_charge_materials(SolidLoadChargeMaterial const & material) From 2401d55c312e05b36111c9436f449a76daa58373 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 10 Feb 2020 09:54:46 -0500 Subject: [PATCH 044/217] Added comment to SQLite.cpp --- src/sqlite/SQLite.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index a1c0ccf4..4e435725 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -1215,11 +1215,6 @@ void SQLite::create_tables() void SQLite::insert_default_data() { - /* - for( auto const & pump : get_default_pump_data() ) { - insert_pump_data(pump); - } - */ for( auto const & material : get_default_solid_load_charge_materials() ) { insert_solid_load_charge_materials(material); } @@ -1241,14 +1236,9 @@ void SQLite::insert_default_data() for( auto const & surface : get_default_wall_losses_surface() ) { insert_wall_losses_surface(surface); } - /* - for( auto const & pump : get_default_pump_data() ) { - insert_pump_data(pump); - } - */ ///* // On Linux at least, if this ofstream variable is declared, pump table default data correctly populates. If it is not declared, the pump default - // data does not populate. Note that this is true only for the bindings. C++ unit tests work fine in any case. + // data does not populate. Note that this is true only for the bindings/JS unit tests. C++ unit tests work fine in any case. std::ofstream fout; //fout.open("debug.txt", std::ios::app); for( auto const & pump : get_default_pump_data() ) { From 3e7be72e1da5a3e0e6d41a72d52306fee46a79f7 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:28:34 -0500 Subject: [PATCH 045/217] Delete Dockerfile --- Dockerfile | 147 ----------------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6ec75bff..00000000 --- a/Dockerfile +++ /dev/null @@ -1,147 +0,0 @@ -FROM ubuntu:18.04 - -WORKDIR /home/ - -RUN apt -y update -RUN apt -y upgrade - -# Install gcc -RUN apt -y install build-essential -RUN apt-get -y install manpages-dev -RUN gcc --version - -# Install Python -RUN apt-get -y install python -RUN python --version - -# Install curl -RUN apt -y install curl - -# Install cmake -RUN apt -y install cmake -RUN cmake --version - -# Install ccmake -RUN apt -y install cmake-curses-gui -RUN ccmake --version - -# Install Doxygen -RUN apt -y install doxygen -RUN doxygen --version - -# -------------------------------------------------------------------------------------------- - -# Install nvm, node and npm -#RUN touch ~/.bash_profile -#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash -# replace shell with bash so we can source files -#RUN rm /bin/sh && ln -s /bin/bash /bin/sh -#RUN source ~/.nvm/nvm.sh \ nvm --version -#RUN export NVM_DIR="$HOME/.nvm" -#RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -#RUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -#RUN nvm --version - - - -# replace shell with bash so we can source files -RUN rm /bin/sh && ln -s /bin/bash /bin/sh - -# update the repository sources list -# and install dependencies -RUN apt-get update \ - && apt-get install -y curl \ - && apt-get -y autoclean - -# nvm environment variables -ENV NVM_DIR /usr/local/nvm -ENV NODE_VERSION 12.8.0 - -# install nvm -# https://github.com/creationix/nvm#install-script -RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash - -# install node and npm -RUN source $NVM_DIR/nvm.sh \ - && nvm install $NODE_VERSION \ - && nvm alias default $NODE_VERSION \ - && nvm use default - -# add node and npm to path so the commands are available -ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules -ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH - -# confirm installation -RUN node -v -RUN npm -v -# --------------------------------------------------------------------------------------------- - -# --------------------------------------------------------------------------------------------- -# This section is currently inactive - -# Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) -#RUN nvm install node -#RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - -#RUN apt-get install -y nodejs -#RUN node --version -#RUN npm --version - -# Install npm -#RUN apt -y install npm -#RUN npm --version -# --------------------------------------------------------------------------------------------- - -# Install gyp -RUN npm install -g node-gyp@4.0.0 -RUN node-gyp -v - - -# Add AMO-Tools-Suite -RUN mkdir AMO -RUN mkdir AMO/AMO-Tools-Suite -# Inside AMO-Tools-Suite directory -ADD . /home/AMO/AMO-Tools-Suite/ - - -#RUN touch package.json -WORKDIR /home/AMO/AMO-Tools-Suite/ - -# Install Node Tap (test suite) -# @12.6.0, --save-dev -RUN npm install tap@12.6.0 --save-dev -#RUN apt -y install node-tap -#RUN tap --version - -WORKDIR /home/ - -# Install emacs -RUN apt-get -y install emacs -RUN emacs --version - -# Install sqlite3 -RUN apt-get install sqlite3 libsqlite3-dev -RUN sqlite3 --version - - -# Commands to run for building/testing/running AMO-Tools-Suite -# ------------------------------------------------------------- -WORKDIR /home/AMO/AMO-Tools-Suite/ - -RUN cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - -RUN cmake --build . - -RUN ./bin/amo_tools_suite_tests - -RUN npm install - -RUN node-gyp rebuild - -RUN npm run test - -RUN npm run at - -RUN cat debug.txt -#-------------------------------------------------------------- - -#WORKDIR /home/ From d2b0be3b00741d0dde628bb47f280f7456a17c52 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:28:58 -0500 Subject: [PATCH 046/217] Delete commands.txt --- commands.txt | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 commands.txt diff --git a/commands.txt b/commands.txt deleted file mode 100644 index 88b2d3d3..00000000 --- a/commands.txt +++ /dev/null @@ -1,36 +0,0 @@ -docker image build -t comma64/ornl:issue-258 . -docker run -t -d --name amo-suite comma64/ornl:issue-258 -docker exec -it amo-suite /bin/bash -docker container rm --force amo-suite - -docker login -docker push comma64/ornl:issue-258 - - - -docker stop $(docker ps -aq) 2>/dev/null || true -docker rm $(docker ps -a -q) 2>/dev/null|| true -docker rmi $(docker images -q) 2>/dev/null || true -docker image prune -fa || sudo systemctl restart docker -docker system prune -fa || sudo systemctl restart docker - - -# Commands to run for building/testing/running AMO-Tools-Suite -# ------------------------------------------------------------- - -cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ -alternatively: ccmake . - -cmake --build . --target amo_tools_suite_tests -alternatively: cmake --build . - -./bin/amo_tools_suite_tests - -npm install (OR (if necessary): npm install --unsafe-perm) -alternatively (if already installed): node-gyp rebuild - -npm run test - -npm run at -#-------------------------------------------------------------- - From eaa4f1e0a425e9f50ce1a1b24372adbd035f585a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 11:06:17 -0500 Subject: [PATCH 047/217] Added Docker --- Docker/Dockerfile | 145 +++++++++++++++++++++++++++++++++++++ Docker/docker_commands.txt | 36 +++++++++ 2 files changed, 181 insertions(+) create mode 100644 Docker/Dockerfile create mode 100644 Docker/docker_commands.txt diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 00000000..ae3d5b6a --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,145 @@ +FROM ubuntu:18.04 + +WORKDIR /home/ + +RUN apt -y update +RUN apt -y upgrade + +# Install gcc +RUN apt -y install build-essential +RUN apt-get -y install manpages-dev +RUN gcc --version + +# Install Python +RUN apt-get -y install python +RUN python --version + +# Install curl +RUN apt -y install curl + +# Install cmake +RUN apt -y install cmake +RUN cmake --version + +# Install ccmake +RUN apt -y install cmake-curses-gui +RUN ccmake --version + +# Install Doxygen +RUN apt -y install doxygen +RUN doxygen --version + +# -------------------------------------------------------------------------------------------- + +# Install nvm, node and npm +#RUN touch ~/.bash_profile +#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +# replace shell with bash so we can source files +#RUN rm /bin/sh && ln -s /bin/bash /bin/sh +#RUN source ~/.nvm/nvm.sh \ nvm --version +#RUN export NVM_DIR="$HOME/.nvm" +#RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +#RUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +#RUN nvm --version + + + +# replace shell with bash so we can source files +RUN rm /bin/sh && ln -s /bin/bash /bin/sh + +# update the repository sources list +# and install dependencies +RUN apt-get update \ + && apt-get install -y curl \ + && apt-get -y autoclean + +# nvm environment variables +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 12.8.0 + +# install nvm +# https://github.com/creationix/nvm#install-script +RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash + +# install node and npm +RUN source $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +# add node and npm to path so the commands are available +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +# confirm installation +RUN node -v +RUN npm -v +# --------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------- +# This section is currently inactive + +# Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) +#RUN nvm install node +#RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +#RUN apt-get install -y nodejs +#RUN node --version +#RUN npm --version + +# Install npm +#RUN apt -y install npm +#RUN npm --version +# --------------------------------------------------------------------------------------------- + +# Install gyp +RUN npm install -g node-gyp@4.0.0 +RUN node-gyp -v + + +# Add AMO-Tools-Suite +RUN mkdir AMO +RUN mkdir AMO/AMO-Tools-Suite +# Inside AMO-Tools-Suite directory +ADD . /home/AMO/AMO-Tools-Suite/ + + +#RUN touch package.json +WORKDIR /home/AMO/AMO-Tools-Suite/ + +# Install Node Tap (test suite) +# @12.6.0, --save-dev +RUN npm install tap@12.6.0 --save-dev +#RUN apt -y install node-tap +#RUN tap --version + +WORKDIR /home/ + +# Install emacs +RUN apt-get -y install emacs +RUN emacs --version + +# Install sqlite3 +RUN apt-get install sqlite3 libsqlite3-dev +RUN sqlite3 --version + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- +WORKDIR /home/AMO/AMO-Tools-Suite/ + +RUN cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ + +RUN cmake --build . + +RUN ./bin/amo_tools_suite_tests + +RUN npm install + +RUN node-gyp rebuild + +RUN npm run test + +RUN npm run at +#-------------------------------------------------------------- + +#WORKDIR /home/ diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt new file mode 100644 index 00000000..536d3998 --- /dev/null +++ b/Docker/docker_commands.txt @@ -0,0 +1,36 @@ +docker image build -f Docker/Dockerfile -t comma64/ornl:issue-258 . +docker run -t -d --name amo-suite comma64/ornl:issue-258 +docker exec -it amo-suite /bin/bash +docker container rm --force amo-suite + +docker login +docker push comma64/ornl:issue-258 + + + +docker stop $(docker ps -aq) 2>/dev/null || true +docker rm $(docker ps -a -q) 2>/dev/null|| true +docker rmi $(docker images -q) 2>/dev/null || true +docker image prune -fa || sudo systemctl restart docker +docker system prune -fa || sudo systemctl restart docker + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- + +cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ +alternatively: ccmake . + +cmake --build . --target amo_tools_suite_tests +alternatively: cmake --build . + +./bin/amo_tools_suite_tests + +npm install (OR (if necessary): npm install --unsafe-perm) +alternatively (if already installed): node-gyp rebuild + +npm run test + +npm run at +#-------------------------------------------------------------- + From f63035c31baefca8d0458d8516ffaafe824699f8 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 13:06:02 -0500 Subject: [PATCH 048/217] Added MotorData.h and MotorData.cpp files --- CMakeLists.txt | 5 +- Docker/Dockerfile | 145 ++++++++++++ Docker/docker_commands.txt | 36 +++ include/sqlite/MotorData.h | 27 +++ src/calculator/motor/MotorData.cpp | 360 +++++++++++++++++++++++++++++ 5 files changed, 572 insertions(+), 1 deletion(-) create mode 100644 Docker/Dockerfile create mode 100644 Docker/docker_commands.txt create mode 100644 include/sqlite/MotorData.h create mode 100644 src/calculator/motor/MotorData.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ad83ca7..1d469bc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,8 @@ set(SOURCE_FILES src/calculator/util/insulation/services/ReynoldsNumber.cpp src/calculator/util/insulation/services/ThermalResistance.cpp src/calculator/util/SteamReduction.cpp - src/calculator/pump/PumpData.cpp) + src/calculator/pump/PumpData.cpp + src/calculator/motor/MotorData.cpp) set(INCLUDE_FILES include/results/Results.h @@ -375,6 +376,8 @@ set(INCLUDE_FILES include/ssmt/HeatExchanger.h include/calculator/pump/PumpData.h include/sqlite/PumpData.h + include/calculator/motor/MotorData.h + include/sqlite/MotorData.h ) # Pending: PumpData calculator unit test diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 00000000..ae3d5b6a --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,145 @@ +FROM ubuntu:18.04 + +WORKDIR /home/ + +RUN apt -y update +RUN apt -y upgrade + +# Install gcc +RUN apt -y install build-essential +RUN apt-get -y install manpages-dev +RUN gcc --version + +# Install Python +RUN apt-get -y install python +RUN python --version + +# Install curl +RUN apt -y install curl + +# Install cmake +RUN apt -y install cmake +RUN cmake --version + +# Install ccmake +RUN apt -y install cmake-curses-gui +RUN ccmake --version + +# Install Doxygen +RUN apt -y install doxygen +RUN doxygen --version + +# -------------------------------------------------------------------------------------------- + +# Install nvm, node and npm +#RUN touch ~/.bash_profile +#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +# replace shell with bash so we can source files +#RUN rm /bin/sh && ln -s /bin/bash /bin/sh +#RUN source ~/.nvm/nvm.sh \ nvm --version +#RUN export NVM_DIR="$HOME/.nvm" +#RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +#RUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +#RUN nvm --version + + + +# replace shell with bash so we can source files +RUN rm /bin/sh && ln -s /bin/bash /bin/sh + +# update the repository sources list +# and install dependencies +RUN apt-get update \ + && apt-get install -y curl \ + && apt-get -y autoclean + +# nvm environment variables +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 12.8.0 + +# install nvm +# https://github.com/creationix/nvm#install-script +RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash + +# install node and npm +RUN source $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + +# add node and npm to path so the commands are available +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +# confirm installation +RUN node -v +RUN npm -v +# --------------------------------------------------------------------------------------------- + +# --------------------------------------------------------------------------------------------- +# This section is currently inactive + +# Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) +#RUN nvm install node +#RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - +#RUN apt-get install -y nodejs +#RUN node --version +#RUN npm --version + +# Install npm +#RUN apt -y install npm +#RUN npm --version +# --------------------------------------------------------------------------------------------- + +# Install gyp +RUN npm install -g node-gyp@4.0.0 +RUN node-gyp -v + + +# Add AMO-Tools-Suite +RUN mkdir AMO +RUN mkdir AMO/AMO-Tools-Suite +# Inside AMO-Tools-Suite directory +ADD . /home/AMO/AMO-Tools-Suite/ + + +#RUN touch package.json +WORKDIR /home/AMO/AMO-Tools-Suite/ + +# Install Node Tap (test suite) +# @12.6.0, --save-dev +RUN npm install tap@12.6.0 --save-dev +#RUN apt -y install node-tap +#RUN tap --version + +WORKDIR /home/ + +# Install emacs +RUN apt-get -y install emacs +RUN emacs --version + +# Install sqlite3 +RUN apt-get install sqlite3 libsqlite3-dev +RUN sqlite3 --version + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- +WORKDIR /home/AMO/AMO-Tools-Suite/ + +RUN cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ + +RUN cmake --build . + +RUN ./bin/amo_tools_suite_tests + +RUN npm install + +RUN node-gyp rebuild + +RUN npm run test + +RUN npm run at +#-------------------------------------------------------------- + +#WORKDIR /home/ diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt new file mode 100644 index 00000000..f88030e2 --- /dev/null +++ b/Docker/docker_commands.txt @@ -0,0 +1,36 @@ +docker image build -f Docker/Dockerfile -t comma64/ornl:issue-469 . +docker run -t -d --name amo-suite comma64/ornl:issue-469 +docker exec -it amo-suite /bin/bash +docker container rm --force amo-suite + +docker login +docker push comma64/ornl:issue-469 + + + +docker stop $(docker ps -aq) 2>/dev/null || true +docker rm $(docker ps -a -q) 2>/dev/null|| true +docker rmi $(docker images -q) 2>/dev/null || true +docker image prune -fa || sudo systemctl restart docker +docker system prune -fa || sudo systemctl restart docker + + +# Commands to run for building/testing/running AMO-Tools-Suite +# ------------------------------------------------------------- + +cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ +alternatively: ccmake . + +cmake --build . --target amo_tools_suite_tests +alternatively: cmake --build . + +./bin/amo_tools_suite_tests + +npm install (OR (if necessary): npm install --unsafe-perm) +alternatively (if already installed): node-gyp rebuild + +npm run test + +npm run at +#-------------------------------------------------------------- + diff --git a/include/sqlite/MotorData.h b/include/sqlite/MotorData.h new file mode 100644 index 00000000..21146d4c --- /dev/null +++ b/include/sqlite/MotorData.h @@ -0,0 +1,27 @@ +#ifndef AMO_TOOLS_SUITE_MOTORDATADB_H +#define AMO_TOOLS_SUITE_MOTORDATADB_H + +class MotorData; + +std::vector SQLite::get_default_motor_data() { + return { + { + "GE", "X$D Ultra IEEE 841", "M9455", "NEMA Design B", 50, 1800, 1780, "TEFC", "326T", 460, + "IEEE 841 Petroleum/Chemical", 0, 0, 0, 0, 1.15, "F", 511, 4, 615, 99.5, 5, 38, 48, 94.5, 94.7, + 94.3, 91.6, 78, 73.6, 63.3, 41.5, 147.4, 294.8, 206.4, 63.5, 25.7, 362.5, 92.9, 115.2, 2000 + }, + { + "WEG Electric", "W22-NEMA Premium SD", "20018ET3G447", "NEMA Design B", 200, 1800, 0, "TEFC", + "447/9T", 460, "undefined", 0, 0, 0, 0, 1.15, "undefined", 1899, 21098, 0, 0, 0, 0, 96.2, 96.2, + 95.4, 0, 85, 82, 73, 0, 582, 1455, 1396.8, 230, 0, 1564, 16, 35, 0, 0 + }, + { + "Teco/Westinghouse", "MAX-E2/841", "HB2004", "NEMA Design B", 200, 1800, 1786, "TEFC", "447T", 460, + "undefined", 0, 0, 0, 0, 1.15, "F", 2420, 23132, 0, 0, 0, 0, 96.2, 95.8, 95,0, 84.5, 82.5, 78.5,0, + 588, 1234.8, 705.6, 230, 46.4, 1450, 0, 0, 0, 0 + } + }; +} + + +#endif //AMO_TOOLS_SUITE_MOTORDATADB_H \ No newline at end of file diff --git a/src/calculator/motor/MotorData.cpp b/src/calculator/motor/MotorData.cpp new file mode 100644 index 00000000..cd25afa3 --- /dev/null +++ b/src/calculator/motor/MotorData.cpp @@ -0,0 +1,360 @@ +/** + * @file + * @brief Contains the implementation of the MotorData calculator/table ORM class + * + * @author Colin Causey (causeyc) + * @bug No known bugs. + * + */ + +#include "calculator/motor/MotorData.h" + +MotorData::MotorData(std::string manufacturer, std::string model, std::string catalog, std::string motorType, int hp, int speed, int fullLoadSpeed, std::string enclosureType, std::string frameNumber, + int voltageRating, std::string purpose, int uFrame, int cFace, int verticalShaft, int dFlange, double serviceFactor, std::string insulationClass, double weight, double listPrice, + double windingResistance, double warranty, int rotorBars, int statorSlots, double efficiency100, double efficiency75, double efficiency50, double efficiency25, double powerFactor100, + double powerFactor75, double powerFactor50, double powerFactor25, double torqueFullLoad, double torqueBreakDown, double torqueLockedRotor, double ampsFullLoad, double ampsIdle, + double ampsLockedRotor, double stalledRotorTimeHot, double stalledRotorTimeCold, double peakVoltage0ms, double peakVoltage5ms) + : manufacturer(std::move(manufacturer)), model(std::move(model)), catalog(std::move(catalog)), motorType(std::move(motorType)), enclosureType(std::move(enclosureType)), + frameNumber(std::move(frameNumber)), purpose(std::move(purpose)), insulationClass(std::move(insulationClass)), hp(hp), speed(speed), fullLoadSpeed(fullLoadSpeed), + voltageRating(voltageRating), uFrame(uFrame), cFace(cFace), verticalShaft(verticalShaft), dFlange(dFlange), rotorBars(rotorBars), statorSlots(statorSlots), serviceFactor(serviceFactor), + weight(weight), listPrice(listPrice), windingResistance(windingResistance), warranty(warranty), efficiency100(efficiency100), efficiency75(efficiency75), efficiency50(efficiency50), + efficiency25(efficiency25), powerFactor100(powerFactor100), powerFactor75(powerFactor75), powerFactor50(powerFactor50), powerFactor25(powerFactor25), torqueFullLoad(torqueFullLoad), + torqueBreakDown(torqueBreakDown), torqueLockedRotor(torqueLockedRotor), ampsFullLoad(ampsFullLoad), ampsIdle(ampsIdle), ampsLockedRotor(ampsLockedRotor), + stalledRotorTimeHot(stalledRotorTimeHot), stalledRotorTimeCold(stalledRotorTimeCold), peakVoltage0ms(peakVoltage0ms), peakVoltage5ms(peakVoltage5ms) +{} + +const std::string &MotorData::getManufacturer() const { + return manufacturer; +} + +void MotorData::setManufacturer(const std::string &manufacturer) { + MotorData::manufacturer = manufacturer; +} + +const std::string &MotorData::getModel() const { + return model; +} + +void MotorData::setModel(const std::string &model) { + MotorData::model = model; +} + +const std::string &MotorData::getCatalog() const { + return catalog; +} + +void MotorData::setCatalog(const std::string &catalog) { + MotorData::catalog = catalog; +} + +const std::string &MotorData::getMotorType() const { + return motorType; +} + +void MotorData::setMotorType(const std::string &motorType) { + MotorData::motorType = motorType; +} + +const std::string &MotorData::getEnclosureType() const { + return enclosureType; +} + +void MotorData::setEnclosureType(const std::string &enclosureType) { + MotorData::enclosureType = enclosureType; +} + +const std::string &MotorData::getFrameNumber() const { + return frameNumber; +} + +void MotorData::setFrameNumber(const std::string &frameNumber) { + MotorData::frameNumber = frameNumber; +} + +const std::string &MotorData::getPurpose() const { + return purpose; +} + +void MotorData::setPurpose(const std::string &purpose) { + MotorData::purpose = purpose; +} + +const std::string &MotorData::getInsulationClass() const { + return insulationClass; +} + +void MotorData::setInsulationClass(const std::string &insulationClass) { + MotorData::insulationClass = insulationClass; +} + +int MotorData::getHp() const { + return hp; +} + +void MotorData::setHp(int hp) { + MotorData::hp = hp; +} + +int MotorData::getSpeed() const { + return speed; +} + +void MotorData::setSpeed(int speed) { + MotorData::speed = speed; +} + +int MotorData::getFullLoadSpeed() const { + return fullLoadSpeed; +} + +void MotorData::setFullLoadSpeed(int fullLoadSpeed) { + MotorData::fullLoadSpeed = fullLoadSpeed; +} + +int MotorData::getVoltageRating() const { + return voltageRating; +} + +void MotorData::setVoltageRating(int voltageRating) { + MotorData::voltageRating = voltageRating; +} + +int MotorData::getUFrame() const { + return uFrame; +} + +void MotorData::setUFrame(int uFrame) { + MotorData::uFrame = uFrame; +} + +int MotorData::getCFace() const { + return cFace; +} + +void MotorData::setCFace(int cFace) { + MotorData::cFace = cFace; +} + +int MotorData::getVerticalShaft() const { + return verticalShaft; +} + +void MotorData::setVerticalShaft(int verticalShaft) { + MotorData::verticalShaft = verticalShaft; +} + +int MotorData::getDFlange() const { + return dFlange; +} + +void MotorData::setDFlange(int dFlange) { + MotorData::dFlange = dFlange; +} + +int MotorData::getRotorBars() const { + return rotorBars; +} + +void MotorData::setRotorBars(int rotorBars) { + MotorData::rotorBars = rotorBars; +} + +int MotorData::getStatorSlots() const { + return statorSlots; +} + +void MotorData::setStatorSlots(int statorSlots) { + MotorData::statorSlots = statorSlots; +} + +double MotorData::getServiceFactor() const { + return serviceFactor; +} + +void MotorData::setServiceFactor(double serviceFactor) { + MotorData::serviceFactor = serviceFactor; +} + +double MotorData::getWeight() const { + return weight; +} + +void MotorData::setWeight(double weight) { + MotorData::weight = weight; +} + +double MotorData::getListPrice() const { + return listPrice; +} + +void MotorData::setListPrice(double listPrice) { + MotorData::listPrice = listPrice; +} + +double MotorData::getWindingResistance() const { + return windingResistance; +} + +void MotorData::setWindingResistance(double windingResistance) { + MotorData::windingResistance = windingResistance; +} + +double MotorData::getWarranty() const { + return warranty; +} + +void MotorData::setWarranty(double warranty) { + MotorData::warranty = warranty; +} + +double MotorData::getEfficiency100() const { + return efficiency100; +} + +void MotorData::setEfficiency100(double efficiency100) { + MotorData::efficiency100 = efficiency100; +} + +double MotorData::getEfficiency75() const { + return efficiency75; +} + +void MotorData::setEfficiency75(double efficiency75) { + MotorData::efficiency75 = efficiency75; +} + +double MotorData::getEfficiency50() const { + return efficiency50; +} + +void MotorData::setEfficiency50(double efficiency50) { + MotorData::efficiency50 = efficiency50; +} + +double MotorData::getEfficiency25() const { + return efficiency25; +} + +void MotorData::setEfficiency25(double efficiency25) { + MotorData::efficiency25 = efficiency25; +} + +double MotorData::getPowerFactor100() const { + return powerFactor100; +} + +void MotorData::setPowerFactor100(double powerFactor100) { + MotorData::powerFactor100 = powerFactor100; +} + +double MotorData::getPowerFactor75() const { + return powerFactor75; +} + +void MotorData::setPowerFactor75(double powerFactor75) { + MotorData::powerFactor75 = powerFactor75; +} + +double MotorData::getPowerFactor50() const { + return powerFactor50; +} + +void MotorData::setPowerFactor50(double powerFactor50) { + MotorData::powerFactor50 = powerFactor50; +} + +double MotorData::getPowerFactor25() const { + return powerFactor25; +} + +void MotorData::setPowerFactor25(double powerFactor25) { + MotorData::powerFactor25 = powerFactor25; +} + +double MotorData::getTorqueFullLoad() const { + return torqueFullLoad; +} + +void MotorData::setTorqueFullLoad(double torqueFullLoad) { + MotorData::torqueFullLoad = torqueFullLoad; +} + +double MotorData::getTorqueBreakDown() const { + return torqueBreakDown; +} + +void MotorData::setTorqueBreakDown(double torqueBreakDown) { + MotorData::torqueBreakDown = torqueBreakDown; +} + +double MotorData::getTorqueLockedRotor() const { + return torqueLockedRotor; +} + +void MotorData::setTorqueLockedRotor(double torqueLockedRotor) { + MotorData::torqueLockedRotor = torqueLockedRotor; +} + +double MotorData::getAmpsFullLoad() const { + return ampsFullLoad; +} + +void MotorData::setAmpsFullLoad(double ampsFullLoad) { + MotorData::ampsFullLoad = ampsFullLoad; +} + +double MotorData::getAmpsIdle() const { + return ampsIdle; +} + +void MotorData::setAmpsIdle(double ampsIdle) { + MotorData::ampsIdle = ampsIdle; +} + +double MotorData::getAmpsLockedRotor() const { + return ampsLockedRotor; +} + +void MotorData::setAmpsLockedRotor(double ampsLockedRotor) { + MotorData::ampsLockedRotor = ampsLockedRotor; +} + +double MotorData::getStalledRotorTimeHot() const { + return stalledRotorTimeHot; +} + +void MotorData::setStalledRotorTimeHot(double stalledRotorTimeHot) { + MotorData::stalledRotorTimeHot = stalledRotorTimeHot; +} + +double MotorData::getStalledRotorTimeCold() const { + return stalledRotorTimeCold; +} + +void MotorData::setStalledRotorTimeCold(double stalledRotorTimeCold) { + MotorData::stalledRotorTimeCold = stalledRotorTimeCold; +} + +double MotorData::getPeakVoltage0ms() const { + return peakVoltage0ms; +} + +void MotorData::setPeakVoltage0ms(double peakVoltage0ms) { + MotorData::peakVoltage0ms = peakVoltage0ms; +} + +double MotorData::getPeakVoltage5ms() const { + return peakVoltage5ms; +} + +void MotorData::setPeakVoltage5ms(double peakVoltage5ms) { + MotorData::peakVoltage5ms = peakVoltage5ms; +} + +int MotorData::getId() const { + return id; +} + +void MotorData::setId(int id) { + this->id = id; +} \ No newline at end of file From da5faf21461c40c76ddb298994bc3d4b611305de Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 13:44:33 -0500 Subject: [PATCH 049/217] Added MotorData table to SQLite.cpp --- binding.gyp | 1 + src/sqlite/SQLite.cpp | 467 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 466 insertions(+), 2 deletions(-) diff --git a/binding.gyp b/binding.gyp index 26753bb8..b908e943 100644 --- a/binding.gyp +++ b/binding.gyp @@ -176,6 +176,7 @@ 'bindings/db.cpp', 'third_party/sqlite/sqlite3.c', 'src/calculator/pump/PumpData.cpp', + 'src/calculator/motor/MotorData.cpp', "'src/calculator/losses/'+f).join(' '))\")", "'src/sqlite/'+f).join(' '))\")", ], diff --git a/src/sqlite/SQLite.cpp b/src/sqlite/SQLite.cpp index 4e435725..15dd108b 100644 --- a/src/sqlite/SQLite.cpp +++ b/src/sqlite/SQLite.cpp @@ -19,7 +19,7 @@ #include #include #include -//#include +#include #include SQLite::SQLite(std::string const & db_name, bool init_db) @@ -96,7 +96,12 @@ SQLite::~SQLite() sqlite3_finalize(m_wall_losses_surface_update_stmt); sqlite3_finalize(m_wall_losses_surface_delete_stmt); - // TODO: Add motor here + sqlite3_finalize(m_motor_data_insert_stmt); + sqlite3_finalize(m_motor_data_select_stmt); + sqlite3_finalize(m_motor_data_select_single_stmt); + sqlite3_finalize(m_motor_data_select_custom_stmt); + sqlite3_finalize(m_motor_data_update_stmt); + sqlite3_finalize(m_motor_data_delete_stmt); sqlite3_finalize(m_pump_data_insert_stmt); sqlite3_finalize(m_pump_data_select_stmt); @@ -483,6 +488,180 @@ WallLosses SQLite::getWallLossesSurfaceById(int id) const return get_object(m_wall_losses_surface_select_single_stmt, id, cb); } +std::vector SQLite::getMotorData() const +{ + auto cb = [] (sqlite3_stmt * stmt) { + auto const id = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const catalog = convert_text(sqlite3_column_text(stmt, 4)); + auto const motorType = convert_text(sqlite3_column_text(stmt, 5)); + auto const hp = sqlite3_column_int(stmt, 6); + auto const speed = sqlite3_column_int(stmt, 7); + auto const fullLoadSpeed = sqlite3_column_int(stmt, 8); + auto const enclosureType = convert_text(sqlite3_column_text(stmt, 9)); + auto const frameNumber = convert_text(sqlite3_column_text(stmt, 10)); + auto const voltageRating = sqlite3_column_int(stmt, 11); + auto const purpose = convert_text(sqlite3_column_text(stmt, 12)); + auto const uFrame = sqlite3_column_int(stmt, 13); + auto const cFace = sqlite3_column_int(stmt, 14); + auto const verticalShaft = sqlite3_column_int(stmt, 15); + auto const dFlange = sqlite3_column_int(stmt, 16); + auto const serviceFactor = sqlite3_column_double(stmt, 17); + auto const insulationClass = convert_text(sqlite3_column_text(stmt, 18)); + auto const weight = sqlite3_column_double(stmt, 19); + auto const listPrice = sqlite3_column_double(stmt, 20); + auto const windingResistance = sqlite3_column_double(stmt, 21); + auto const warranty = sqlite3_column_double(stmt, 22); + auto const rotorBars = sqlite3_column_int(stmt, 23); + auto const statorSlots = sqlite3_column_int(stmt, 24); + auto const efficiency100 = sqlite3_column_double(stmt, 25); + auto const efficiency75 = sqlite3_column_double(stmt, 26); + auto const efficiency50 = sqlite3_column_double(stmt, 27); + auto const efficiency25 = sqlite3_column_double(stmt, 28); + auto const powerFactor100 = sqlite3_column_double(stmt, 29); + auto const powerFactor75 = sqlite3_column_double(stmt, 30); + auto const powerFactor50 = sqlite3_column_double(stmt, 31); + auto const powerFactor25 = sqlite3_column_double(stmt, 32); + auto const torqueFullLoad = sqlite3_column_double(stmt, 33); + auto const torqueBreakDown = sqlite3_column_double(stmt, 34); + auto const torqueLockedRotor = sqlite3_column_double(stmt, 35); + auto const ampsFullLoad = sqlite3_column_double(stmt, 36); + auto const ampsIdle = sqlite3_column_double(stmt, 37); + auto const ampsLockedRotor = sqlite3_column_double(stmt, 38); + auto const stalledRotorTimeHot = sqlite3_column_double(stmt, 39); + auto const stalledRotorTimeCold = sqlite3_column_double(stmt, 40); + auto const peakVoltage0ms = sqlite3_column_double(stmt, 41); + auto const peakVoltage5ms = sqlite3_column_double(stmt, 42); + + auto m = MotorData(manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms); + m.setId(id); + return m; + }; + return get_all_objects(m_motor_data_select_stmt, cb); +} + +std::vector SQLite::getCustomMotorData() const +{ + auto cb = [] (sqlite3_stmt * stmt) { + auto const id = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const catalog = convert_text(sqlite3_column_text(stmt, 4)); + auto const motorType = convert_text(sqlite3_column_text(stmt, 5)); + auto const hp = sqlite3_column_int(stmt, 6); + auto const speed = sqlite3_column_int(stmt, 7); + auto const fullLoadSpeed = sqlite3_column_int(stmt, 8); + auto const enclosureType = convert_text(sqlite3_column_text(stmt, 9)); + auto const frameNumber = convert_text(sqlite3_column_text(stmt, 10)); + auto const voltageRating = sqlite3_column_int(stmt, 11); + auto const purpose = convert_text(sqlite3_column_text(stmt, 12)); + auto const uFrame = sqlite3_column_int(stmt, 13); + auto const cFace = sqlite3_column_int(stmt, 14); + auto const verticalShaft = sqlite3_column_int(stmt, 15); + auto const dFlange = sqlite3_column_int(stmt, 16); + auto const serviceFactor = sqlite3_column_double(stmt, 17); + auto const insulationClass = convert_text(sqlite3_column_text(stmt, 18)); + auto const weight = sqlite3_column_double(stmt, 19); + auto const listPrice = sqlite3_column_double(stmt, 20); + auto const windingResistance = sqlite3_column_double(stmt, 21); + auto const warranty = sqlite3_column_double(stmt, 22); + auto const rotorBars = sqlite3_column_int(stmt, 23); + auto const statorSlots = sqlite3_column_int(stmt, 24); + auto const efficiency100 = sqlite3_column_double(stmt, 25); + auto const efficiency75 = sqlite3_column_double(stmt, 26); + auto const efficiency50 = sqlite3_column_double(stmt, 27); + auto const efficiency25 = sqlite3_column_double(stmt, 28); + auto const powerFactor100 = sqlite3_column_double(stmt, 29); + auto const powerFactor75 = sqlite3_column_double(stmt, 30); + auto const powerFactor50 = sqlite3_column_double(stmt, 31); + auto const powerFactor25 = sqlite3_column_double(stmt, 32); + auto const torqueFullLoad = sqlite3_column_double(stmt, 33); + auto const torqueBreakDown = sqlite3_column_double(stmt, 34); + auto const torqueLockedRotor = sqlite3_column_double(stmt, 35); + auto const ampsFullLoad = sqlite3_column_double(stmt, 36); + auto const ampsIdle = sqlite3_column_double(stmt, 37); + auto const ampsLockedRotor = sqlite3_column_double(stmt, 38); + auto const stalledRotorTimeHot = sqlite3_column_double(stmt, 39); + auto const stalledRotorTimeCold = sqlite3_column_double(stmt, 40); + auto const peakVoltage0ms = sqlite3_column_double(stmt, 41); + auto const peakVoltage5ms = sqlite3_column_double(stmt, 42); + + auto m = MotorData(manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms); + m.setId(id); + return m; + }; + return get_all_objects(m_motor_data_select_custom_stmt, cb); +} + +MotorData SQLite::getMotorDataById(int id) const +{ + auto cb = [] (sqlite3_stmt * stmt) { + auto const dbId = sqlite3_column_int(stmt, 0); + sqlite3_column_int(stmt, 1); + auto const manufacturer = convert_text(sqlite3_column_text(stmt, 2)); + auto const model = convert_text(sqlite3_column_text(stmt, 3)); + auto const catalog = convert_text(sqlite3_column_text(stmt, 4)); + auto const motorType = convert_text(sqlite3_column_text(stmt, 5)); + auto const hp = sqlite3_column_int(stmt, 6); + auto const speed = sqlite3_column_int(stmt, 7); + auto const fullLoadSpeed = sqlite3_column_int(stmt, 8); + auto const enclosureType = convert_text(sqlite3_column_text(stmt, 9)); + auto const frameNumber = convert_text(sqlite3_column_text(stmt, 10)); + auto const voltageRating = sqlite3_column_int(stmt, 11); + auto const purpose = convert_text(sqlite3_column_text(stmt, 12)); + auto const uFrame = sqlite3_column_int(stmt, 13); + auto const cFace = sqlite3_column_int(stmt, 14); + auto const verticalShaft = sqlite3_column_int(stmt, 15); + auto const dFlange = sqlite3_column_int(stmt, 16); + auto const serviceFactor = sqlite3_column_double(stmt, 17); + auto const insulationClass = convert_text(sqlite3_column_text(stmt, 18)); + auto const weight = sqlite3_column_double(stmt, 19); + auto const listPrice = sqlite3_column_double(stmt, 20); + auto const windingResistance = sqlite3_column_double(stmt, 21); + auto const warranty = sqlite3_column_double(stmt, 22); + auto const rotorBars = sqlite3_column_int(stmt, 23); + auto const statorSlots = sqlite3_column_int(stmt, 24); + auto const efficiency100 = sqlite3_column_double(stmt, 25); + auto const efficiency75 = sqlite3_column_double(stmt, 26); + auto const efficiency50 = sqlite3_column_double(stmt, 27); + auto const efficiency25 = sqlite3_column_double(stmt, 28); + auto const powerFactor100 = sqlite3_column_double(stmt, 29); + auto const powerFactor75 = sqlite3_column_double(stmt, 30); + auto const powerFactor50 = sqlite3_column_double(stmt, 31); + auto const powerFactor25 = sqlite3_column_double(stmt, 32); + auto const torqueFullLoad = sqlite3_column_double(stmt, 33); + auto const torqueBreakDown = sqlite3_column_double(stmt, 34); + auto const torqueLockedRotor = sqlite3_column_double(stmt, 35); + auto const ampsFullLoad = sqlite3_column_double(stmt, 36); + auto const ampsIdle = sqlite3_column_double(stmt, 37); + auto const ampsLockedRotor = sqlite3_column_double(stmt, 38); + auto const stalledRotorTimeHot = sqlite3_column_double(stmt, 39); + auto const stalledRotorTimeCold = sqlite3_column_double(stmt, 40); + auto const peakVoltage0ms = sqlite3_column_double(stmt, 41); + auto const peakVoltage5ms = sqlite3_column_double(stmt, 42); + + auto m = MotorData(manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms); + m.setId(dbId); + return m; + }; + return get_object(m_motor_data_select_single_stmt, id, cb); +} + std::vector SQLite::getPumpData() const { auto cb = [] (sqlite3_stmt * stmt) { auto const id = sqlite3_column_int(stmt, 0); @@ -830,6 +1009,38 @@ void SQLite::create_select_stmt() prepare_statement(m_wall_losses_surface_select_custom_stmt, select_custom_wall_losses_surface); + std::string const select_motor_data = + R"(SELECT id, sid, manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms + FROM motor_data)"; + + prepare_statement(m_motor_data_select_stmt, select_motor_data); + + std::string const select_single_motor_data = + R"(SELECT id, sid, manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms + FROM motor_data + WHERE id = ?)"; + + prepare_statement(m_motor_data_select_single_stmt, select_single_motor_data); + + std::string const select_custom_motor_data = + R"(SELECT id, sid, manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms + FROM motor_data + WHERE sid = 1)"; + + prepare_statement(m_motor_data_select_custom_stmt, select_custom_motor_data); + std::string const select_pump_data = R"(SELECT id, sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, @@ -958,6 +1169,23 @@ void SQLite::create_update_and_delete_stmt() { WHERE id=? AND sid = 1)"; prepare_statement(m_wall_losses_surface_update_stmt, update_wall_losses_surface); + + std::string const delete_motor_data = + R"(DELETE from motor_data where id=? and sid=1)"; + + prepare_statement(m_motor_data_delete_stmt, delete_motor_data); + + std::string const update_motor_data = + R"(UPDATE motor_data + SET manufacturer=?, model=?, catalog=?, motorType=?, hp=?, speed=?, fullLoadSpeed=?, enclosureType=?, frameNumber=?, + voltageRating=?, purpose=?, uFrame=?, cFace=?, verticalShaft=?, dFlange=?, serviceFactor=?, insulationClass=?, + weight=?, listPrice=?, windingResistance=?, warranty=?, rotorBars=?, statorSlots=?, efficiency100=?, efficiency75=?, + efficiency50=?, efficiency25=?, powerFactor100=?, powerFactor75=?, powerFactor50=?, powerFactor25=?, torqueFullLoad=?, + torqueBreakDown=?, torqueLockedRotor=?, ampsFullLoad=?, ampsIdle=?, ampsLockedRotor=?, stalledRotorTimeHot=?, + stalledRotorTimeCold=?, peakVoltage0ms=?, peakVoltage5ms=? + WHERE id=? AND sid = 1)"; + + prepare_statement(m_motor_data_update_stmt, update_motor_data); std::string const delete_pump_data = R"(DELETE from pump_data where id=? and sid=1)"; @@ -1026,6 +1254,18 @@ void SQLite::create_insert_stmt() { prepare_statement(m_wall_losses_surface_insert_stmt, wall_losses_surface_insert_sql); + const std::string motor_data_insert_sql = + R"(INSERT INTO motor_data(sid, manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms) + VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))"; + + // 42 entries + + prepare_statement(m_motor_data_insert_stmt, motor_data_insert_sql); + const std::string pump_data_insert_sql = R"(INSERT INTO pump_data(sid, manufacturer, model, type, serialNumber, status, pumpType, radialBearingType, thrustBearingType, shaftOrientation, shaftSealType, fluidType, priority, driveType, flangeConnectionClass, @@ -1150,6 +1390,60 @@ void SQLite::create_tables() execute_command(wall_losses_surface_table_sql); + const std::string motor_table_sql = + R"(CREATE TABLE IF NOT EXISTS motor_data ( + id integer PRIMARY KEY AUTOINCREMENT, + sid integer NOT NULL, + manufacturer text NOT NULL DEFAULT "" UNIQUE, + model text NOT NULL, + catalog text NOT NULL, + motorType text NOT NULL, + hp integer NOT NULL, + speed integer NOT NULL, + fullLoadSpeed integer NOT NULL, + enclosureType text NOT NULL, + frameNumber text NOT NULL, + voltageRating integer NOT NULL, + purpose text NOT NULL, + uFrame integer NOT NULL, + cFace integer NOT NULL, + verticalShaft integer NOT NULL, + dFlange integer NOT NULL, + serviceFactor real NOT NULL, + insulationClass text NOT NULL, + weight real NOT NULL, -- lbs, + listPrice real NOT NULL, -- US dollars, + windingResistance real NOT NULL, -- mOhms at 25C, + warranty real NOT NULL, -- years, + rotorBars integer NOT NULL, + statorSlots integer NOT NULL, + efficiency100 real NOT NULL, + efficiency75 real NOT NULL, + efficiency50 real NOT NULL, + efficiency25 real NOT NULL, + powerFactor100 real NOT NULL, + powerFactor75 real NOT NULL, + powerFactor50 real NOT NULL, + powerFactor25 real NOT NULL, + torqueFullLoad real NOT NULL, + torqueBreakDown real NOT NULL, + torqueLockedRotor real NOT NULL, + ampsFullLoad real NOT NULL, + ampsIdle real NOT NULL, + ampsLockedRotor real NOT NULL, + stalledRotorTimeHot real NOT NULL, -- seconds, + stalledRotorTimeCold real NOT NULL, -- seconds, + peakVoltage0ms real NOT NULL, + peakVoltage5ms real NOT NULL, + UNIQUE (manufacturer, model, catalog, motorType, hp, speed, fullLoadSpeed, enclosureType, frameNumber, voltageRating, purpose, + uFrame, cFace, verticalShaft, dFlange, serviceFactor, insulationClass, weight, listPrice, windingResistance, warranty, + rotorBars, statorSlots, efficiency100, efficiency75, efficiency50, efficiency25, powerFactor100, powerFactor75, powerFactor50, + powerFactor25, torqueFullLoad, torqueBreakDown, torqueLockedRotor, ampsFullLoad, ampsIdle, ampsLockedRotor, stalledRotorTimeHot, + stalledRotorTimeCold, peakVoltage0ms, peakVoltage5ms) + );)"; + + execute_command(motor_table_sql); + const std::string pump_table_sql = R"(CREATE TABLE IF NOT EXISTS pump_data ( id integer PRIMARY KEY AUTOINCREMENT, @@ -1236,6 +1530,9 @@ void SQLite::insert_default_data() for( auto const & surface : get_default_wall_losses_surface() ) { insert_wall_losses_surface(surface); } + for( auto const & motor : get_default_motor_data() ) { + insert_motor_data(motor); + } ///* // On Linux at least, if this ofstream variable is declared, pump table default data correctly populates. If it is not declared, the pump default // data does not populate. Note that this is true only for the bindings/JS unit tests. C++ unit tests work fine in any case. @@ -1667,6 +1964,172 @@ bool SQLite::updateWallLossesSurface(WallLosses const &material) { return valid_insert; } +bool SQLite::insert_motor_data(MotorData const & m) +{ + bind_value(m_motor_data_insert_stmt, 1, 0); + bind_value(m_motor_data_insert_stmt, 2, m.manufacturer); + bind_value(m_motor_data_insert_stmt, 3, m.model); + bind_value(m_motor_data_insert_stmt, 4, m.catalog); + bind_value(m_motor_data_insert_stmt, 5, m.motorType); + bind_value(m_motor_data_insert_stmt, 6, m.hp); + bind_value(m_motor_data_insert_stmt, 7, m.speed); + bind_value(m_motor_data_insert_stmt, 8, m.fullLoadSpeed); + bind_value(m_motor_data_insert_stmt, 9, m.enclosureType); + bind_value(m_motor_data_insert_stmt, 10, m.frameNumber); + bind_value(m_motor_data_insert_stmt, 11, m.voltageRating); + bind_value(m_motor_data_insert_stmt, 12, m.purpose); + bind_value(m_motor_data_insert_stmt, 13, m.uFrame); + bind_value(m_motor_data_insert_stmt, 14, m.cFace); + bind_value(m_motor_data_insert_stmt, 15, m.verticalShaft); + bind_value(m_motor_data_insert_stmt, 16, m.dFlange); + bind_value(m_motor_data_insert_stmt, 17, m.serviceFactor); + bind_value(m_motor_data_insert_stmt, 18, m.insulationClass); + bind_value(m_motor_data_insert_stmt, 19, m.weight); + bind_value(m_motor_data_insert_stmt, 20, m.listPrice); + bind_value(m_motor_data_insert_stmt, 21, m.windingResistance); + bind_value(m_motor_data_insert_stmt, 22, m.warranty); + bind_value(m_motor_data_insert_stmt, 23, m.rotorBars); + bind_value(m_motor_data_insert_stmt, 24, m.statorSlots); + bind_value(m_motor_data_insert_stmt, 25, m.efficiency100); + bind_value(m_motor_data_insert_stmt, 26, m.efficiency75); + bind_value(m_motor_data_insert_stmt, 27, m.efficiency50); + bind_value(m_motor_data_insert_stmt, 28, m.efficiency25); + bind_value(m_motor_data_insert_stmt, 29, m.powerFactor100); + bind_value(m_motor_data_insert_stmt, 30, m.powerFactor75); + bind_value(m_motor_data_insert_stmt, 31, m.powerFactor50); + bind_value(m_motor_data_insert_stmt, 32, m.powerFactor25); + bind_value(m_motor_data_insert_stmt, 33, m.torqueFullLoad); + bind_value(m_motor_data_insert_stmt, 34, m.torqueBreakDown); + bind_value(m_motor_data_insert_stmt, 35, m.torqueLockedRotor); + bind_value(m_motor_data_insert_stmt, 36, m.ampsFullLoad); + bind_value(m_motor_data_insert_stmt, 37, m.ampsIdle); + bind_value(m_motor_data_insert_stmt, 38, m.ampsLockedRotor); + bind_value(m_motor_data_insert_stmt, 39, m.stalledRotorTimeHot); + bind_value(m_motor_data_insert_stmt, 40, m.stalledRotorTimeCold); + bind_value(m_motor_data_insert_stmt, 41, m.peakVoltage0ms); + bind_value(m_motor_data_insert_stmt, 42, m.peakVoltage5ms); + + int rc = step_command(m_motor_data_insert_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_motor_data_insert_stmt); + return valid_insert; +} + +// public API for inserts +bool SQLite::insertMotorData(MotorData const & m){ + bind_value(m_motor_data_insert_stmt, 1, 1); + bind_value(m_motor_data_insert_stmt, 2, m.manufacturer); + bind_value(m_motor_data_insert_stmt, 3, m.model); + bind_value(m_motor_data_insert_stmt, 4, m.catalog); + bind_value(m_motor_data_insert_stmt, 5, m.motorType); + bind_value(m_motor_data_insert_stmt, 6, m.hp); + bind_value(m_motor_data_insert_stmt, 7, m.speed); + bind_value(m_motor_data_insert_stmt, 8, m.fullLoadSpeed); + bind_value(m_motor_data_insert_stmt, 9, m.enclosureType); + bind_value(m_motor_data_insert_stmt, 10, m.frameNumber); + bind_value(m_motor_data_insert_stmt, 11, m.voltageRating); + bind_value(m_motor_data_insert_stmt, 12, m.purpose); + bind_value(m_motor_data_insert_stmt, 13, m.uFrame); + bind_value(m_motor_data_insert_stmt, 14, m.cFace); + bind_value(m_motor_data_insert_stmt, 15, m.verticalShaft); + bind_value(m_motor_data_insert_stmt, 16, m.dFlange); + bind_value(m_motor_data_insert_stmt, 17, m.serviceFactor); + bind_value(m_motor_data_insert_stmt, 18, m.insulationClass); + bind_value(m_motor_data_insert_stmt, 19, m.weight); + bind_value(m_motor_data_insert_stmt, 20, m.listPrice); + bind_value(m_motor_data_insert_stmt, 21, m.windingResistance); + bind_value(m_motor_data_insert_stmt, 22, m.warranty); + bind_value(m_motor_data_insert_stmt, 23, m.rotorBars); + bind_value(m_motor_data_insert_stmt, 24, m.statorSlots); + bind_value(m_motor_data_insert_stmt, 25, m.efficiency100); + bind_value(m_motor_data_insert_stmt, 26, m.efficiency75); + bind_value(m_motor_data_insert_stmt, 27, m.efficiency50); + bind_value(m_motor_data_insert_stmt, 28, m.efficiency25); + bind_value(m_motor_data_insert_stmt, 29, m.powerFactor100); + bind_value(m_motor_data_insert_stmt, 30, m.powerFactor75); + bind_value(m_motor_data_insert_stmt, 31, m.powerFactor50); + bind_value(m_motor_data_insert_stmt, 32, m.powerFactor25); + bind_value(m_motor_data_insert_stmt, 33, m.torqueFullLoad); + bind_value(m_motor_data_insert_stmt, 34, m.torqueBreakDown); + bind_value(m_motor_data_insert_stmt, 35, m.torqueLockedRotor); + bind_value(m_motor_data_insert_stmt, 36, m.ampsFullLoad); + bind_value(m_motor_data_insert_stmt, 37, m.ampsIdle); + bind_value(m_motor_data_insert_stmt, 38, m.ampsLockedRotor); + bind_value(m_motor_data_insert_stmt, 39, m.stalledRotorTimeHot); + bind_value(m_motor_data_insert_stmt, 40, m.stalledRotorTimeCold); + bind_value(m_motor_data_insert_stmt, 41, m.peakVoltage0ms); + bind_value(m_motor_data_insert_stmt, 42, m.peakVoltage5ms); + + int rc = step_command(m_motor_data_insert_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_motor_data_insert_stmt); + return valid_insert; +} + +bool SQLite::deleteMotorData(int id) { + if (isDefaultMaterial(id, get_default_motor_data().size())) { + return false; + } + bind_value(m_motor_data_delete_stmt, 1, id); + int rc = step_command(m_motor_data_delete_stmt); + bool valid_command = step_validity(rc); + reset_command(m_motor_data_delete_stmt); + return valid_command; +} + +bool SQLite::updateMotorData(MotorData const & m) { + if (isDefaultMaterial(m.id, get_default_motor_data().size())) { + return false; + } + bind_value(m_motor_data_update_stmt, 1, m.manufacturer); + bind_value(m_motor_data_update_stmt, 2, m.model); + bind_value(m_motor_data_update_stmt, 3, m.catalog); + bind_value(m_motor_data_update_stmt, 4, m.motorType); + bind_value(m_motor_data_update_stmt, 5, m.hp); + bind_value(m_motor_data_update_stmt, 6, m.speed); + bind_value(m_motor_data_update_stmt, 7, m.fullLoadSpeed); + bind_value(m_motor_data_update_stmt, 8, m.enclosureType); + bind_value(m_motor_data_update_stmt, 9, m.frameNumber); + bind_value(m_motor_data_update_stmt, 10, m.voltageRating); + bind_value(m_motor_data_update_stmt, 11, m.purpose); + bind_value(m_motor_data_update_stmt, 12, m.uFrame); + bind_value(m_motor_data_update_stmt, 13, m.cFace); + bind_value(m_motor_data_update_stmt, 14, m.verticalShaft); + bind_value(m_motor_data_update_stmt, 15, m.dFlange); + bind_value(m_motor_data_update_stmt, 16, m.serviceFactor); + bind_value(m_motor_data_update_stmt, 17, m.insulationClass); + bind_value(m_motor_data_update_stmt, 18, m.weight); + bind_value(m_motor_data_update_stmt, 19, m.listPrice); + bind_value(m_motor_data_update_stmt, 20, m.windingResistance); + bind_value(m_motor_data_update_stmt, 21, m.warranty); + bind_value(m_motor_data_update_stmt, 22, m.rotorBars); + bind_value(m_motor_data_update_stmt, 23, m.statorSlots); + bind_value(m_motor_data_update_stmt, 24, m.efficiency100); + bind_value(m_motor_data_update_stmt, 25, m.efficiency75); + bind_value(m_motor_data_update_stmt, 26, m.efficiency50); + bind_value(m_motor_data_update_stmt, 27, m.efficiency25); + bind_value(m_motor_data_update_stmt, 28, m.powerFactor100); + bind_value(m_motor_data_update_stmt, 29, m.powerFactor75); + bind_value(m_motor_data_update_stmt, 30, m.powerFactor50); + bind_value(m_motor_data_update_stmt, 31, m.powerFactor25); + bind_value(m_motor_data_update_stmt, 32, m.torqueFullLoad); + bind_value(m_motor_data_update_stmt, 33, m.torqueBreakDown); + bind_value(m_motor_data_update_stmt, 34, m.torqueLockedRotor); + bind_value(m_motor_data_update_stmt, 35, m.ampsFullLoad); + bind_value(m_motor_data_update_stmt, 36, m.ampsIdle); + bind_value(m_motor_data_update_stmt, 37, m.ampsLockedRotor); + bind_value(m_motor_data_update_stmt, 38, m.stalledRotorTimeHot); + bind_value(m_motor_data_update_stmt, 39, m.stalledRotorTimeCold); + bind_value(m_motor_data_update_stmt, 40, m.peakVoltage0ms); + bind_value(m_motor_data_update_stmt, 41, m.peakVoltage5ms); + bind_value(m_motor_data_update_stmt, 42, m.id); + + int rc = step_command(m_motor_data_update_stmt); + bool valid_insert = step_validity(rc); + reset_command(m_motor_data_update_stmt); + return valid_insert; +} + bool SQLite::insertPumpData(PumpData const &pump) { bind_value(m_pump_data_insert_stmt, 1, 1); // sid bind_value(m_pump_data_insert_stmt, 2, pump.manufacturer); From ad42179890c9d840fa7b8c16c034e25165d73025 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 14:36:03 -0500 Subject: [PATCH 050/217] Added C++ unit tests to SQLite.unit.cpp for MotorData --- tests/SQLite.unit.cpp | 151 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 142 insertions(+), 9 deletions(-) diff --git a/tests/SQLite.unit.cpp b/tests/SQLite.unit.cpp index c7b7245b..46bcefb8 100644 --- a/tests/SQLite.unit.cpp +++ b/tests/SQLite.unit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -287,6 +288,31 @@ TEST_CASE( "SQLite - update all materials", "[sqlite]" ) { CHECK(Approx(sqlite.getCustomWallLossesSurface().at(1).getConditionFactor()) == 0.75); } + { + MotorData motor1 = {"Beta", "Xtrainer 300", "20018ET3G447", "2 Stroke 300cc", 200, 1800, 0, "TEFC", + "447/9T", 460, "undefined", 0, 0, 0, 0, 1.15, "undefined", 1899, 21098, 0, 0, 0, 0, 96.2, 96.2, + 95.4, 0, 85, 82, 73, 0, 582, 1455, 1396.8, 230, 0, 1564, 16, 35, 0, 0}; + + MotorData motor2 = {"Suzuki", "Drz400", "20018ET3G447", "4 Stroke 398cc", 200, 1800, 0, "TEFC", + "447/9T", 460, "undefined", 0, 0, 0, 0, 1.15, "undefined", 1899, 21098, 0, 0, 0, 0, 96.2, 96.2, + 95.4, 0, 85, 82, 73, 0, 582, 1455, 1396.8, 230, 0, 1564, 16, 35, 0, 0}; + + sqlite.insertMotorData(motor1); + sqlite.insertMotorData(motor2); + + auto custom = sqlite.getCustomMotorData().at(0); + auto custom2 = sqlite.getCustomMotorData().at(1); + + custom.setManufacturer("Beta Motorcycles"); + custom2.setManufacturer("Slow Suzuki"); + + sqlite.updateMotorData(custom); + sqlite.updateMotorData(custom2); + + CHECK(sqlite.getCustomMotorData().at(0).getManufacturer() == "Beta Motorcycles"); + CHECK(sqlite.getCustomMotorData().at(1).getManufacturer() == "Slow Suzuki"); + } + { PumpData pump1("manufacturerCustom1", "modelCustom1", "typeCustom1", "serialNumberCustom1", "statusCustom1", "pumpTypeCustom1", @@ -302,15 +328,6 @@ TEST_CASE( "SQLite - update all materials", "[sqlite]" ) { sqlite.insertPumpData(pump1); sqlite.insertPumpData(pump2); - /* - std::ofstream ofs("debug.txt"); - auto test = sqlite.getPumpData(); - ofs << std::endl; - ofs << "getPumpData() returned size " << test.size() << std::endl; - ofs << std::endl; - ofs.close(); - */ - auto custom1 = sqlite.getCustomPumpData().at(0); auto custom2 = sqlite.getCustomPumpData().at(1); @@ -427,6 +444,21 @@ TEST_CASE( "SQLite - deleteMaterials", "[sqlite]" ) { CHECK( output2[output2.size() - 1].getSurface() == last ); } + { + auto const output = sqlite.getMotorData(); + auto const last = output.back().getManufacturer(); + MotorData motor( + "throw this motor away delete", "X$D Ultra IEEE 841", "M9455", "NEMA Design B", 50, 1800, 1780, "TEFC", "326T", 460, + "IEEE 841 Petroleum/Chemical", 0, 0, 0, 0, 1.15, "F", 511, 4, 615, 99.5, 5, 38, 48, 94.5, 94.7, + 94.3, 91.6, 78, 73.6, 63.3, 41.5, 147.4, 294.8, 206.4, 63.5, 25.7, 362.5, 92.9, 115.2, 2000 + ); + + sqlite.insertMotorData(motor); + sqlite.deleteMotorData(sqlite.getMotorData().back().getId()); + auto const output2 = sqlite.getMotorData(); + CHECK( output2[output2.size() - 1].getManufacturer() == last ); + } + { auto const output = sqlite.getPumpData(); auto const last = output.back().getManufacturer(); @@ -1150,6 +1182,107 @@ TEST_CASE( "SQLite - CustomWallLossesSurface", "[sqlite]" ) { } } +TEST_CASE( "SQLite - Motor Data inserts and updates and selects", "[sqlite][motor]" ) { + auto const compare = [](MotorData result, MotorData expected) { + CHECK(result.getManufacturer() == expected.getManufacturer()); + CHECK(result.getModel() == expected.getModel()); + CHECK(result.getCatalog() == expected.getCatalog()); + CHECK(result.getMotorType() == expected.getMotorType()); + CHECK(result.getHp() == expected.getHp()); + CHECK(result.getSpeed() == expected.getSpeed()); + CHECK(result.getFullLoadSpeed() == expected.getFullLoadSpeed()); + CHECK(result.getEnclosureType() == expected.getEnclosureType()); + CHECK(result.getFrameNumber() == expected.getFrameNumber()); + CHECK(result.getVoltageRating() == expected.getVoltageRating()); + CHECK(result.getPurpose() == expected.getPurpose()); + CHECK(result.getUFrame() == expected.getUFrame()); + CHECK(result.getCFace() == expected.getCFace()); + CHECK(result.getVerticalShaft() == expected.getVerticalShaft()); + CHECK(result.getDFlange() == expected.getDFlange()); + CHECK(result.getServiceFactor() == expected.getServiceFactor()); + CHECK(result.getInsulationClass() == expected.getInsulationClass()); + CHECK(result.getWeight() == expected.getWeight()); + CHECK(result.getListPrice() == expected.getListPrice()); + CHECK(result.getWindingResistance() == expected.getWindingResistance()); + CHECK(result.getWarranty() == expected.getWarranty()); + CHECK(result.getRotorBars() == expected.getRotorBars()); + CHECK(result.getStatorSlots() == expected.getStatorSlots()); + CHECK(result.getEfficiency100() == expected.getEfficiency100()); + CHECK(result.getEfficiency75() == expected.getEfficiency75()); + CHECK(result.getEfficiency50() == expected.getEfficiency50()); + CHECK(result.getEfficiency25() == expected.getEfficiency25()); + CHECK(result.getPowerFactor100() == expected.getPowerFactor100()); + CHECK(result.getPowerFactor75() == expected.getPowerFactor75()); + CHECK(result.getPowerFactor50() == expected.getPowerFactor50()); + CHECK(result.getPowerFactor25() == expected.getPowerFactor25()); + CHECK(result.getTorqueFullLoad() == expected.getTorqueFullLoad()); + CHECK(result.getTorqueBreakDown() == expected.getTorqueBreakDown()); + CHECK(result.getTorqueLockedRotor() == expected.getTorqueLockedRotor()); + CHECK(result.getAmpsFullLoad() == expected.getAmpsFullLoad()); + CHECK(result.getAmpsIdle() == expected.getAmpsIdle()); + CHECK(result.getAmpsLockedRotor() == expected.getAmpsLockedRotor()); + CHECK(result.getStalledRotorTimeHot() == expected.getStalledRotorTimeHot()); + CHECK(result.getStalledRotorTimeCold() == expected.getStalledRotorTimeCold()); + CHECK(result.getPeakVoltage0ms() == expected.getPeakVoltage0ms()); + CHECK(result.getPeakVoltage5ms() == expected.getPeakVoltage5ms()); + CHECK(result.getId() == expected.getId()); + }; + + auto sqlite = SQLite(":memory:", true); + + { + auto const motors = sqlite.getMotorData(); + + auto expected1 = MotorData( + "GE", "X$D Ultra IEEE 841", "M9455", "NEMA Design B", 50, 1800, 1780, "TEFC", "326T", 460, + "IEEE 841 Petroleum/Chemical", 0, 0, 0, 0, 1.15, "F", 511, 4, 615, 99.5, 5, 38, 48, 94.5, 94.7, + 94.3, 91.6, 78, 73.6, 63.3, 41.5, 147.4, 294.8, 206.4, 63.5, 25.7, 362.5, 92.9, 115.2, 2000 + ); + expected1.setId(1); + + auto motor = sqlite.getMotorDataById(1); + compare(motors.at(0), expected1); + + auto expected2 = MotorData( + "WEG Electric", "W22-NEMA Premium SD", "20018ET3G447", "NEMA Design B", 200, 1800, 0, "TEFC", + "447/9T", 460, "undefined", 0, 0, 0, 0, 1.15, "undefined", 1899, 21098, 0, 0, 0, 0, 96.2, 96.2, + 95.4, 0, 85, 82, 73, 0, 582, 1455, 1396.8, 230, 0, 1564, 16, 35, 0, 0 + ); + expected2.setId(2); + + motor = sqlite.getMotorDataById(2); + compare(motor, expected2); + + auto expected3 = MotorData( + "Teco/Westinghouse", "MAX-E2/841", "HB2004", "NEMA Design B", 200, 1800, 1786, "TEFC", "447T", 460, + "undefined", 0, 0, 0, 0, 1.15, "F", 2420, 23132, 0, 0, 0, 0, 96.2, 95.8, 95,0, 84.5, 82.5, 78.5,0, + 588, 1234.8, 705.6, 230, 46.4, 1450, 0, 0, 0, 0 + ); + expected3.setId(3); + + motor = sqlite.getMotorDataById(3); + } + + { + auto ktm = MotorData( + "KTM", "Freeride-e", "KTM Motors 2018", "electric motor", 24, 4500, 5000, "TEFC", + "447/9T", 260, "to provide hours of fun on a single charge", 0, 0, 0, 0, 1.15, "undefined", 60, 5000, 0, 2, 0, 0, 96.2, 96.2, + 95.4, 0, 85, 82, 73, 0, 42, 42, 42, 230, 0, 1564, 16, 35, 300, 300 + ); + ktm.setId(4); + + sqlite.insertMotorData(ktm); + auto const motors = sqlite.getMotorData(); + compare(ktm, motors.back()); + + auto const customMotors = sqlite.getCustomMotorData(); + compare(ktm, customMotors[0]); + + sqlite.deleteMotorData(ktm.getId()); + CHECK(sqlite.getCustomMotorData().size() == 0); + } +} + TEST_CASE( "SQLite - Pump Data inserts and updates and selects", "[sqlite][pump]" ) { auto const compare = [](PumpData result, PumpData expected) { CHECK(result.getManufacturer() == expected.getManufacturer()); From e6cd4bee9f01f7c2ee1d4c58847b4c0c43b90d1f Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 14:56:29 -0500 Subject: [PATCH 051/217] Added MotorData bindings --- bindings/db.cpp | 15 +++++++ bindings/db.h | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/bindings/db.cpp b/bindings/db.cpp index 7cd084c8..97c10b26 100644 --- a/bindings/db.cpp +++ b/bindings/db.cpp @@ -113,6 +113,21 @@ NAN_MODULE_INIT(InitDb) { Nan::Set(target, New("updateWallLossesSurface").ToLocalChecked(), GetFunction(New(updateWallLossesSurface)).ToLocalChecked()); + + Nan::Set(target, New("selectMotors").ToLocalChecked(), + GetFunction(New(selectMotors)).ToLocalChecked()); + + Nan::Set(target, New("selectMotorById").ToLocalChecked(), + GetFunction(New(selectMotorById)).ToLocalChecked()); + + Nan::Set(target, New("insertMotor").ToLocalChecked(), + GetFunction(New(insertMotor)).ToLocalChecked()); + + Nan::Set(target, New("deleteMotor").ToLocalChecked(), + GetFunction(New(deleteMotor)).ToLocalChecked()); + + Nan::Set(target, New("updateMotor").ToLocalChecked(), + GetFunction(New(updateMotor)).ToLocalChecked()); Nan::Set(target, New("selectPumps").ToLocalChecked(), GetFunction(New(selectPumps)).ToLocalChecked()); diff --git a/bindings/db.h b/bindings/db.h index c84dc434..2b802f3e 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -14,6 +14,7 @@ #include #include #include +#include #include using namespace Nan; @@ -61,6 +62,51 @@ inline void SetObj(Local &obj, const std::string &key, const std::string //Nan::Set(obj, Nan::New(static_cast(key)).ToLocalChecked(), Nan::New(val).ToLocalChecked()); } +void SetMotorData(Local & obj, const MotorData & motor) { + SetObj(obj, "id", motor.getId()); + SetObj(obj, "manufacturer", motor.getManufacturer()); + SetObj(obj, "model", motor.getModel()); + SetObj(obj, "catalog", motor.getCatalog()); + SetObj(obj, "motorType", motor.getMotorType()); + SetObj(obj, "hp", motor.getHp()); + SetObj(obj, "speed", motor.getSpeed()); + SetObj(obj, "fullLoadSpeed", motor.getFullLoadSpeed()); + SetObj(obj, "enclosureType", motor.getEnclosureType()); + SetObj(obj, "frameNumber", motor.getFrameNumber()); + SetObj(obj, "voltageRating", motor.getVoltageRating()); + SetObj(obj, "purpose", motor.getPurpose()); + SetObj(obj, "uFrame", motor.getUFrame()); + SetObj(obj, "cFace", motor.getCFace()); + SetObj(obj, "verticalShaft", motor.getVerticalShaft()); + SetObj(obj, "dFlange", motor.getDFlange()); + SetObj(obj, "serviceFactor", motor.getServiceFactor()); + SetObj(obj, "insulationClass", motor.getInsulationClass()); + SetObj(obj, "weight", motor.getWeight()); + SetObj(obj, "listPrice", motor.getListPrice()); + SetObj(obj, "windingResistance", motor.getWindingResistance()); + SetObj(obj, "warranty", motor.getWarranty()); + SetObj(obj, "rotorBars", motor.getRotorBars()); + SetObj(obj, "statorSlots", motor.getStatorSlots()); + SetObj(obj, "efficiency100", motor.getEfficiency100()); + SetObj(obj, "efficiency75", motor.getEfficiency75()); + SetObj(obj, "efficiency50", motor.getEfficiency50()); + SetObj(obj, "efficiency25", motor.getEfficiency25()); + SetObj(obj, "powerFactor100", motor.getPowerFactor100()); + SetObj(obj, "powerFactor75", motor.getPowerFactor75()); + SetObj(obj, "powerFactor50", motor.getPowerFactor50()); + SetObj(obj, "powerFactor25", motor.getPowerFactor25()); + SetObj(obj, "torqueFullLoad", motor.getTorqueFullLoad()); + SetObj(obj, "torqueBreakDown", motor.getTorqueBreakDown()); + SetObj(obj, "torqueLockedRotor", motor.getTorqueLockedRotor()); + SetObj(obj, "ampsFullLoad", motor.getAmpsFullLoad()); + SetObj(obj, "ampsIdle", motor.getAmpsIdle()); + SetObj(obj, "ampsLockedRotor", motor.getAmpsLockedRotor()); + SetObj(obj, "stalledRotorTimeHot", motor.getStalledRotorTimeHot()); + SetObj(obj, "stalledRotorTimeCold", motor.getStalledRotorTimeCold()); + SetObj(obj, "peakVoltage0ms", motor.getPeakVoltage0ms()); + SetObj(obj, "peakVoltage5ms", motor.getPeakVoltage5ms()); +} + void SetPumpData(Local & obj, const PumpData & pump) { SetObj(obj, "id", pump.getId()); SetObj(obj, "manufacturer", pump.getManufacturer()); @@ -766,6 +812,69 @@ NAN_METHOD(selectWallLossesSurfaceById) info.GetReturnValue().Set(obj); }; +NAN_METHOD(selectMotors) { + auto const motors = sql->getMotorData(); + + auto motorsNan = Nan::New(); + for (std::size_t i = 0; i < motors.size(); i++) { + Local motor = Nan::New(); + SetMotorData(motor, motors[i]); + Nan::Set(motorsNan, i, motor); + } + + info.GetReturnValue().Set(motorsNan); +}; + +NAN_METHOD(selectMotorById) { + Local motor = Nan::New(); + try { + SetMotorData(motor, sql->getMotorDataById(static_cast(Nan::To(info[0]).FromJust()))); + } catch (std::runtime_error const & e) { + std::string const what = e.what(); + ThrowError(std::string("std::runtime_error thrown in selectMotorById - db.h: " + what).c_str()); + } + info.GetReturnValue().Set(motor); +}; + +NAN_METHOD(insertMotor) { + inp = Nan::To(info[0]).ToLocalChecked(); + MotorData motor(GetStr("manufacturer"), GetStr("model"), GetStr("catalog"), GetStr("motorType"), + Get("hp"), Get("speed"), Get("fullLoadSpeed"), GetStr("enclosureType"), GetStr("frameNumber"), + Get("voltageRating"), GetStr("purpose"), Get("uFrame"), Get("cFace"), Get("verticalShaft"), Get("dFlange"), + Get("serviceFactor"), GetStr("insulationClass"), Get("weight"), Get("listPrice"), Get("windingResistance"), + Get("warranty"), Get("rotorBars"), Get("statorSlots"), Get("efficiency100"), Get("efficiency75"), + Get("efficiency50"), Get("efficiency25"), Get("powerFactor100"), Get("powerFactor75"), Get("powerFactor50"), + Get("powerFactor25"), Get("torqueFullLoad"), Get("torqueBreakDown"), Get("torqueLockedRotor"), + Get("ampsFullLoad"), Get("ampsIdle"), Get("ampsLockedRotor"), Get("stalledRotorTimeHot"), + Get("stalledRotorTimeCold"), Get("peakVoltage0ms"), Get("peakVoltage5ms") + ); + bool success = sql->insertMotorData(motor); + info.GetReturnValue().Set(success); +}; + +NAN_METHOD(deleteMotor) { + bool success = sql->deleteMotorData(static_cast(Nan::To(info[0]).FromJust())); + info.GetReturnValue().Set(success); +}; + +NAN_METHOD(updateMotor) { + inp = Nan::To(info[0]).ToLocalChecked(); + MotorData motor(GetStr("manufacturer"), GetStr("model"), GetStr("catalog"), GetStr("motorType"), + Get("hp"), Get("speed"), Get("fullLoadSpeed"), GetStr("enclosureType"), GetStr("frameNumber"), + Get("voltageRating"), GetStr("purpose"), Get("uFrame"), Get("cFace"), Get("verticalShaft"), Get("dFlange"), + Get("serviceFactor"), GetStr("insulationClass"), Get("weight"), Get("listPrice"), Get("windingResistance"), + Get("warranty"), Get("rotorBars"), Get("statorSlots"), Get("efficiency100"), Get("efficiency75"), + Get("efficiency50"), Get("efficiency25"), Get("powerFactor100"), Get("powerFactor75"), Get("powerFactor50"), + Get("powerFactor25"), Get("torqueFullLoad"), Get("torqueBreakDown"), Get("torqueLockedRotor"), + Get("ampsFullLoad"), Get("ampsIdle"), Get("ampsLockedRotor"), Get("stalledRotorTimeHot"), + Get("stalledRotorTimeCold"), Get("peakVoltage0ms"), Get("peakVoltage5ms") + ); + + motor.setId(Get("id")); + bool success = sql->insertMotorData(motor); + info.GetReturnValue().Set(success); +}; + NAN_METHOD(selectPumps) { auto const pumps = sql->getPumpData(); // TODO this returns 0 pumps confirmed, but doesn't in C++. I don't think I can do anything else here anymore. From 602c7a2b169a30969fca789760190f60e0efacca Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 11 Feb 2020 16:25:48 -0500 Subject: [PATCH 052/217] Added dbSelectMotorData unit test to dbBindingsTest.js --- bindings/db.h | 4 +- tests/js/dbBindingsTest.js | 108 +++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index 2b802f3e..f1e9a4b7 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -170,8 +170,8 @@ NAN_METHOD(startup) // sql.reset(); // sql = std::unique_ptr(new SQLite(dbName, ! fileExists)); - std::string const dbName = ":memory:"; - //std::string const dbName = "test.db"; + //std::string const dbName = ":memory:"; + std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); } diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index a4e66cd6..f961986b 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -482,6 +482,114 @@ test('dbInsertWallLossesSurface', function (t) { t.equal(res[size].conditionFactor, obj2.conditionFactor, res[size].conditionFactor + " != " + obj2.conditionFactor); }); +test('dbSelectMotorData', function (t) { + t.plan(87); + bindings.startup(); + + t.type(bindings.selectMotorById, 'function'); + var res = bindings.selectMotorById(1); + + var obj = { + id: 1, manufacturer: "GE", model: "X$D Ultra IEEE 841", catalog: "M9455", motorType: "NEMA Design B", hp: 50, speed:1800, + fullLoadSpeed: 1780, enclosureType: "TEFC", frameNumber: "326T", voltageRating: 460, + purpose: "IEEE 841 Petroleum/Chemical", uFrame: 0, cFace: 0, verticalShaft: 0, dFlange: 0, serviceFactor: 1.15, insulationClass: "F", + weight: 511, listPrice: 4, windingResistance: 615, warranty: 99.5, rotorBars: 5, statorSlots: 38, efficiency100: 48, + efficiency75: 94.5, efficiency50: 94.7, efficiency25: 94.3, powerFactor100: 91.6, powerFactor75: 78, powerFactor50: 73.6, + powerFactor25: 63.3, torqueFullLoad: 41.5, torqueBreakDown: 147.4, torqueLockedRotor: 294.8, ampsFullLoad: 206.4, ampsIdle: 63.5, + ampsLockedRotor: 25.7, stalledRotorTimeHot: 362.5, stalledRotorTimeCold: 92.9, peakVoltage0ms: 115.2, peakVoltage5ms: 2000 + }; + + t.equal(res.id, obj.id, res.id + " != " + obj.id); + t.equal(res.manufacturer, obj.manufacturer, res.manufacturer + " != " + obj.manufacturer); + t.equal(res.model, obj.model, res.model + " != " + obj.model); + t.equal(res.catalog, obj.catalog, res.catalog + " != " + obj.catalog); + t.equal(res.motorType, obj.motorType, res.motorType + " != " + obj.motorType); + t.equal(res.hp, obj.hp, res.hp + " != " + obj.hp); + t.equal(res.speed, obj.speed, res.speed + " != " + obj.speed); + t.equal(res.fullLoadSpeed, obj.fullLoadSpeed, res.fullLoadSpeed + " != " + obj.fullLoadSpeed); + t.equal(res.enclosureType, obj.enclosureType, res.enclosureType + " != " + obj.enclosureType); + t.equal(res.frameNumber, obj.frameNumber, res.frameNumber + " != " + obj.frameNumber); + t.equal(res.voltageRating, obj.voltageRating, res.voltageRating + " != " + obj.voltageRating); + t.equal(res.purpose, obj.purpose, res.purpose + " != " + obj.purpose); + t.equal(res.uFrame, obj.uFrame, res.uFrame + " != " + obj.uFrame); + t.equal(res.cFace, obj.cFace, res.cFace + " != " + obj.cFace); + t.equal(res.verticalShaft, obj.verticalShaft, res.verticalShaft + " != " + obj.verticalShaft); + t.equal(res.dFlange, obj.dFlange, res.dFlange + " != " + obj.dFlange); + t.equal(res.serviceFactor, obj.serviceFactor, res.serviceFactor + " != " + obj.serviceFactor); + t.equal(res.insulationClass, obj.insulationClass, res.insulationClass + " != " + obj.insulationClass); + t.equal(res.weight, obj.weight, res.weight + " != " + obj.weight); + t.equal(res.listPrice, obj.listPrice, res.listPrice + " != " + obj.listPrice); + t.equal(res.windingResistance, obj.windingResistance, res.windingResistance + " != " + obj.windingResistance); + t.equal(res.warranty, obj.warranty, res.warranty + " != " + obj.warranty); + t.equal(res.rotorBars, obj.rotorBars, res.rotorBars + " != " + obj.rotorBars); + t.equal(res.statorSlots, obj.statorSlots, res.statorSlots + " != " + obj.statorSlots); + t.equal(res.efficiency100, obj.efficiency100, res.efficiency100 + " != " + obj.efficiency100); + t.equal(res.efficiency75, obj.efficiency75, res.efficiency75 + " != " + obj.efficiency75); + t.equal(res.efficiency50, obj.efficiency50, res.efficiency50 + " != " + obj.efficiency50); + t.equal(res.efficiency25, obj.efficiency25, res.efficiency25 + " != " + obj.efficiency25); + t.equal(res.powerFactor100, obj.powerFactor100, res.powerFactor100 + " != " + obj.powerFactor100); + t.equal(res.powerFactor75, obj.powerFactor75, res.powerFactor75 + " != " + obj.powerFactor75); + t.equal(res.powerFactor50, obj.powerFactor50, res.powerFactor50 + " != " + obj.powerFactor50); + t.equal(res.powerFactor25, obj.powerFactor25, res.powerFactor25 + " != " + obj.powerFactor25); + t.equal(res.torqueFullLoad, obj.torqueFullLoad, res.torqueFullLoad + " != " + obj.torqueFullLoad); + t.equal(res.torqueBreakDown, obj.torqueBreakDown, res.torqueBreakDown + " != " + obj.torqueBreakDown); + t.equal(res.torqueLockedRotor, obj.torqueLockedRotor, res.torqueLockedRotor + " != " + obj.torqueLockedRotor); + t.equal(res.ampsFullLoad, obj.ampsFullLoad, res.ampsFullLoad + " != " + obj.ampsFullLoad); + t.equal(res.ampsIdle, obj.ampsIdle, res.ampsIdle + " != " + obj.ampsIdle); + t.equal(res.ampsLockedRotor, obj.ampsLockedRotor, res.ampsLockedRotor + " != " + obj.ampsLockedRotor); + t.equal(res.stalledRotorTimeHot, obj.stalledRotorTimeHot, res.stalledRotorTimeHot + " != " + obj.stalledRotorTimeHot); + t.equal(res.stalledRotorTimeCold, obj.stalledRotorTimeCold, res.stalledRotorTimeCold + " != " + obj.stalledRotorTimeCold); + t.equal(res.peakVoltage0ms, obj.peakVoltage0ms, res.peakVoltage0ms + " != " + obj.peakVoltage0ms); + t.equal(res.peakVoltage5ms, obj.peakVoltage5ms, res.peakVoltage5ms + " != " + obj.peakVoltage5ms); + + t.type(bindings.selectMotors, 'function'); + res = bindings.selectMotors(); + + t.equal(res.length, 3, "array is not size 3"); + t.equal(res[0].id, obj.id, res[0].id + " != " + obj.id); + t.equal(res[0].manufacturer, obj.manufacturer, res[0].manufacturer + " != " + obj.manufacturer); + t.equal(res[0].model, obj.model, res[0].model + " != " + obj.model); + t.equal(res[0].catalog, obj.catalog, res[0].catalog + " != " + obj.catalog); + t.equal(res[0].motorType, obj.motorType, res[0].motorType + " != " + obj.motorType); + t.equal(res[0].hp, obj.hp, res[0].hp + " != " + obj.hp); + t.equal(res[0].speed, obj.speed, res[0].speed + " != " + obj.speed); + t.equal(res[0].fullLoadSpeed, obj.fullLoadSpeed, res[0].fullLoadSpeed + " != " + obj.fullLoadSpeed); + t.equal(res[0].enclosureType, obj.enclosureType, res[0].enclosureType + " != " + obj.enclosureType); + t.equal(res[0].frameNumber, obj.frameNumber, res[0].frameNumber + " != " + obj.frameNumber); + t.equal(res[0].voltageRating, obj.voltageRating, res[0].voltageRating + " != " + obj.voltageRating); + t.equal(res[0].purpose, obj.purpose, res[0].purpose + " != " + obj.purpose); + t.equal(res[0].uFrame, obj.uFrame, res[0].uFrame + " != " + obj.uFrame); + t.equal(res[0].cFace, obj.cFace, res[0].cFace + " != " + obj.cFace); + t.equal(res[0].verticalShaft, obj.verticalShaft, res[0].verticalShaft + " != " + obj.verticalShaft); + t.equal(res[0].dFlange, obj.dFlange, res[0].dFlange + " != " + obj.dFlange); + t.equal(res[0].serviceFactor, obj.serviceFactor, res[0].serviceFactor + " != " + obj.serviceFactor); + t.equal(res[0].insulationClass, obj.insulationClass, res[0].insulationClass + " != " + obj.insulationClass); + t.equal(res[0].weight, obj.weight, res[0].weight + " != " + obj.weight); + t.equal(res[0].listPrice, obj.listPrice, res[0].listPrice + " != " + obj.listPrice); + t.equal(res[0].windingResistance, obj.windingResistance, res[0].windingResistance + " != " + obj.windingResistance); + t.equal(res[0].warranty, obj.warranty, res[0].warranty + " != " + obj.warranty); + t.equal(res[0].rotorBars, obj.rotorBars, res[0].rotorBars + " != " + obj.rotorBars); + t.equal(res[0].statorSlots, obj.statorSlots, res[0].statorSlots + " != " + obj.statorSlots); + t.equal(res[0].efficiency100, obj.efficiency100, res[0].efficiency100 + " != " + obj.efficiency100); + t.equal(res[0].efficiency75, obj.efficiency75, res[0].efficiency75 + " != " + obj.efficiency75); + t.equal(res[0].efficiency50, obj.efficiency50, res[0].efficiency50 + " != " + obj.efficiency50); + t.equal(res[0].efficiency25, obj.efficiency25, res[0].efficiency25 + " != " + obj.efficiency25); + t.equal(res[0].powerFactor100, obj.powerFactor100, res[0].powerFactor100 + " != " + obj.powerFactor100); + t.equal(res[0].powerFactor75, obj.powerFactor75, res[0].powerFactor75 + " != " + obj.powerFactor75); + t.equal(res[0].powerFactor50, obj.powerFactor50, res[0].powerFactor50 + " != " + obj.powerFactor50); + t.equal(res[0].powerFactor25, obj.powerFactor25, res[0].powerFactor25 + " != " + obj.powerFactor25); + t.equal(res[0].torqueFullLoad, obj.torqueFullLoad, res[0].torqueFullLoad + " != " + obj.torqueFullLoad); + t.equal(res[0].torqueBreakDown, obj.torqueBreakDown, res[0].torqueBreakDown + " != " + obj.torqueBreakDown); + t.equal(res[0].torqueLockedRotor, obj.torqueLockedRotor, res[0].torqueLockedRotor + " != " + obj.torqueLockedRotor); + t.equal(res[0].ampsFullLoad, obj.ampsFullLoad, res[0].ampsFullLoad + " != " + obj.ampsFullLoad); + t.equal(res[0].ampsIdle, obj.ampsIdle, res[0].ampsIdle + " != " + obj.ampsIdle); + t.equal(res[0].ampsLockedRotor, obj.ampsLockedRotor, res[0].ampsLockedRotor + " != " + obj.ampsLockedRotor); + t.equal(res[0].stalledRotorTimeHot, obj.stalledRotorTimeHot, res[0].stalledRotorTimeHot + " != " + obj.stalledRotorTimeHot); + t.equal(res[0].stalledRotorTimeCold, obj.stalledRotorTimeCold, res[0].stalledRotorTimeCold + " != " + obj.stalledRotorTimeCold); + t.equal(res[0].peakVoltage0ms, obj.peakVoltage0ms, res[0].peakVoltage0ms + " != " + obj.peakVoltage0ms); + t.equal(res[0].peakVoltage5ms, obj.peakVoltage5ms, res[0].peakVoltage5ms + " != " + obj.peakVoltage5ms); +}); + test('dbSelectPumpData', function (t) { t.plan(97); //2 bindings.startup(); From bb841403e296db0a4a5523d87d60d7ca1e5a1a85 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 12 Feb 2020 09:21:29 -0500 Subject: [PATCH 053/217] Added dbInsertMotor unit test to dbBindingsTest.js --- bindings/db.h | 4 +-- tests/js/dbBindingsTest.js | 66 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/bindings/db.h b/bindings/db.h index f1e9a4b7..2b802f3e 100644 --- a/bindings/db.h +++ b/bindings/db.h @@ -170,8 +170,8 @@ NAN_METHOD(startup) // sql.reset(); // sql = std::unique_ptr(new SQLite(dbName, ! fileExists)); - //std::string const dbName = ":memory:"; - std::string const dbName = "test.db"; + std::string const dbName = ":memory:"; + //std::string const dbName = "test.db"; sql.reset(); sql = std::unique_ptr(new SQLite(dbName, true)); } diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index f961986b..9beb73d2 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -590,6 +590,72 @@ test('dbSelectMotorData', function (t) { t.equal(res[0].peakVoltage5ms, obj.peakVoltage5ms, res[0].peakVoltage5ms + " != " + obj.peakVoltage5ms); }); +test('dbInsertMotor', function (t) { + t.plan(44); + bindings.startup(); + + t.type(bindings.insertPump, 'function'); + + var obj = { + id: 4, manufacturer: "A", model: "B", catalog: "C", motorType: "D", hp: 50, speed:1800, + fullLoadSpeed: 1780, enclosureType: "E", frameNumber: "F", voltageRating: 460, + purpose: "G", uFrame: 0, cFace: 0, verticalShaft: 0, dFlange: 0, serviceFactor: 1.15, insulationClass: "H", + weight: 511, listPrice: 4, windingResistance: 615, warranty: 99.5, rotorBars: 5, statorSlots: 38, efficiency100: 48, + efficiency75: 94.5, efficiency50: 94.7, efficiency25: 94.3, powerFactor100: 91.6, powerFactor75: 78, powerFactor50: 73.6, + powerFactor25: 63.3, torqueFullLoad: 41.5, torqueBreakDown: 147.4, torqueLockedRotor: 294.8, ampsFullLoad: 206.4, ampsIdle: 63.5, + ampsLockedRotor: 25.7, stalledRotorTimeHot: 362.5, stalledRotorTimeCold: 92.9, peakVoltage0ms: 115.2, peakVoltage5ms: 2000 + }; + + var res = bindings.selectMotors(); + var size = res.length; + bindings.insertMotor(obj); + res = bindings.selectMotors(); + + t.equal(res.length, size + 1, res.length + " != " + (size + 1)); + t.equal(res[size].id, obj.id, res[size].id + " != " + obj.id); + t.equal(res[size].manufacturer, obj.manufacturer, res[size].manufacturer + " != " + obj.manufacturer); + t.equal(res[size].model, obj.model, res[size].model + " != " + obj.model); + t.equal(res[size].catalog, obj.catalog, res[size].catalog + " != " + obj.catalog); + t.equal(res[size].motorType, obj.motorType, res[size].motorType + " != " + obj.motorType); + t.equal(res[size].hp, obj.hp, res[size].hp + " != " + obj.hp); + t.equal(res[size].speed, obj.speed, res[size].speed + " != " + obj.speed); + t.equal(res[size].fullLoadSpeed, obj.fullLoadSpeed, res[size].fullLoadSpeed + " != " + obj.fullLoadSpeed); + t.equal(res[size].enclosureType, obj.enclosureType, res[size].enclosureType + " != " + obj.enclosureType); + t.equal(res[size].frameNumber, obj.frameNumber, res[size].frameNumber + " != " + obj.frameNumber); + t.equal(res[size].voltageRating, obj.voltageRating, res[size].voltageRating + " != " + obj.voltageRating); + t.equal(res[size].purpose, obj.purpose, res[size].purpose + " != " + obj.purpose); + t.equal(res[size].uFrame, obj.uFrame, res[size].uFrame + " != " + obj.uFrame); + t.equal(res[size].cFace, obj.cFace, res[size].cFace + " != " + obj.cFace); + t.equal(res[size].verticalShaft, obj.verticalShaft, res[size].verticalShaft + " != " + obj.verticalShaft); + t.equal(res[size].dFlange, obj.dFlange, res[size].dFlange + " != " + obj.dFlange); + t.equal(res[size].serviceFactor, obj.serviceFactor, res[size].serviceFactor + " != " + obj.serviceFactor); + t.equal(res[size].insulationClass, obj.insulationClass, res[size].insulationClass + " != " + obj.insulationClass); + t.equal(res[size].weight, obj.weight, res[size].weight + " != " + obj.weight); + t.equal(res[size].listPrice, obj.listPrice, res[size].listPrice + " != " + obj.listPrice); + t.equal(res[size].windingResistance, obj.windingResistance, res[size].windingResistance + " != " + obj.windingResistance); + t.equal(res[size].warranty, obj.warranty, res[size].warranty + " != " + obj.warranty); + t.equal(res[size].rotorBars, obj.rotorBars, res[size].rotorBars + " != " + obj.rotorBars); + t.equal(res[size].statorSlots, obj.statorSlots, res[size].statorSlots + " != " + obj.statorSlots); + t.equal(res[size].efficiency100, obj.efficiency100, res[size].efficiency100 + " != " + obj.efficiency100); + t.equal(res[size].efficiency75, obj.efficiency75, res[size].efficiency75 + " != " + obj.efficiency75); + t.equal(res[size].efficiency50, obj.efficiency50, res[size].efficiency50 + " != " + obj.efficiency50); + t.equal(res[size].efficiency25, obj.efficiency25, res[size].efficiency25 + " != " + obj.efficiency25); + t.equal(res[size].powerFactor100, obj.powerFactor100, res[size].powerFactor100 + " != " + obj.powerFactor100); + t.equal(res[size].powerFactor75, obj.powerFactor75, res[size].powerFactor75 + " != " + obj.powerFactor75); + t.equal(res[size].powerFactor50, obj.powerFactor50, res[size].powerFactor50 + " != " + obj.powerFactor50); + t.equal(res[size].powerFactor25, obj.powerFactor25, res[size].powerFactor25 + " != " + obj.powerFactor25); + t.equal(res[size].torqueFullLoad, obj.torqueFullLoad, res[size].torqueFullLoad + " != " + obj.torqueFullLoad); + t.equal(res[size].torqueBreakDown, obj.torqueBreakDown, res[size].torqueBreakDown + " != " + obj.torqueBreakDown); + t.equal(res[size].torqueLockedRotor, obj.torqueLockedRotor, res[size].torqueLockedRotor + " != " + obj.torqueLockedRotor); + t.equal(res[size].ampsFullLoad, obj.ampsFullLoad, res[size].ampsFullLoad + " != " + obj.ampsFullLoad); + t.equal(res[size].ampsIdle, obj.ampsIdle, res[size].ampsIdle + " != " + obj.ampsIdle); + t.equal(res[size].ampsLockedRotor, obj.ampsLockedRotor, res[size].ampsLockedRotor + " != " + obj.ampsLockedRotor); + t.equal(res[size].stalledRotorTimeHot, obj.stalledRotorTimeHot, res[size].stalledRotorTimeHot + " != " + obj.stalledRotorTimeHot); + t.equal(res[size].stalledRotorTimeCold, obj.stalledRotorTimeCold, res[size].stalledRotorTimeCold + " != " + obj.stalledRotorTimeCold); + t.equal(res[size].peakVoltage0ms, obj.peakVoltage0ms, res[size].peakVoltage0ms + " != " + obj.peakVoltage0ms); + t.equal(res[size].peakVoltage5ms, obj.peakVoltage5ms, res[size].peakVoltage5ms + " != " + obj.peakVoltage5ms); +}); + test('dbSelectPumpData', function (t) { t.plan(97); //2 bindings.startup(); From e238e48f88c78ef45d5e02b502622e7aa79d644c Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 12 Feb 2020 09:55:12 -0500 Subject: [PATCH 054/217] Added Motor test to dbDeletions unit test in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index 9beb73d2..ee5dbc48 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -858,7 +858,7 @@ test('dbInsertPump', function (t) { }); test('dbDeletions', function (t) { - t.plan(8); + t.plan(9); bindings.startup(); var res = bindings.selectLiquidLoadChargeMaterials(); @@ -983,6 +983,22 @@ test('dbDeletions', function (t) { bindings.deletePump(bindings.selectPumps().length); res = bindings.selectPumps(); t.equal(last, res[res.length - 1].id); + + res = bindings.selectMotors(); + last = res[res.length - 1].id; + obj = { + id: 4, manufacturer: "A", model: "B", catalog: "C", motorType: "D", hp: 50, speed:1800, + fullLoadSpeed: 1780, enclosureType: "E", frameNumber: "F", voltageRating: 460, + purpose: "G", uFrame: 0, cFace: 0, verticalShaft: 0, dFlange: 0, serviceFactor: 1.15, insulationClass: "H", + weight: 511, listPrice: 4, windingResistance: 615, warranty: 99.5, rotorBars: 5, statorSlots: 38, efficiency100: 48, + efficiency75: 94.5, efficiency50: 94.7, efficiency25: 94.3, powerFactor100: 91.6, powerFactor75: 78, powerFactor50: 73.6, + powerFactor25: 63.3, torqueFullLoad: 41.5, torqueBreakDown: 147.4, torqueLockedRotor: 294.8, ampsFullLoad: 206.4, ampsIdle: 63.5, + ampsLockedRotor: 25.7, stalledRotorTimeHot: 362.5, stalledRotorTimeCold: 92.9, peakVoltage0ms: 115.2, peakVoltage5ms: 2000 + }; + bindings.insertMotor(obj); + bindings.deleteMotor(bindings.selectMotors().length); + res = bindings.selectMotors(); + t.equal(last, res[res.length - 1].id); }); test('dbUpdates', function (t) { From 62a07374609e129e4a49e272d238b41f05ecf37b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 12 Feb 2020 10:12:41 -0500 Subject: [PATCH 055/217] Added Motor test to dbUpdates unit test in dbBindingsTest.js --- tests/js/dbBindingsTest.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index ee5dbc48..ace9e93e 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -1002,7 +1002,7 @@ test('dbDeletions', function (t) { }); test('dbUpdates', function (t) { - t.plan(8); + t.plan(9); bindings.startup(); var obj = { @@ -1120,6 +1120,21 @@ test('dbUpdates', function (t) { pump.manufacturer = 'updated'; bindings.updatePump(pump); t.equal(bindings.selectPumpById(bindings.selectPumps().length).manufacturer, 'updated'); + + obj = { + id: 4, manufacturer: "A", model: "B", catalog: "C", motorType: "D", hp: 50, speed:1800, + fullLoadSpeed: 1780, enclosureType: "E", frameNumber: "F", voltageRating: 460, + purpose: "G", uFrame: 0, cFace: 0, verticalShaft: 0, dFlange: 0, serviceFactor: 1.15, insulationClass: "H", + weight: 511, listPrice: 4, windingResistance: 615, warranty: 99.5, rotorBars: 5, statorSlots: 38, efficiency100: 48, + efficiency75: 94.5, efficiency50: 94.7, efficiency25: 94.3, powerFactor100: 91.6, powerFactor75: 78, powerFactor50: 73.6, + powerFactor25: 63.3, torqueFullLoad: 41.5, torqueBreakDown: 147.4, torqueLockedRotor: 294.8, ampsFullLoad: 206.4, ampsIdle: 63.5, + ampsLockedRotor: 25.7, stalledRotorTimeHot: 362.5, stalledRotorTimeCold: 92.9, peakVoltage0ms: 115.2, peakVoltage5ms: 2000 + }; + bindings.insertMotor(obj); + motor = bindings.selectMotorById(bindings.selectMotors().length); + motor.manufacturer = 'updated'; + bindings.updateMotor(motor); + t.equal(bindings.selectMotorById(bindings.selectMotors().length).manufacturer, 'updated'); }); From 00e6f913b252540d60b48853d452fdba32d43e69 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:17:40 -0500 Subject: [PATCH 056/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 97fb4447..900ba88a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: cpp os: - linux - osx + - windows compiler: - gcc From 70c6215f29c6ef88aff96407aec1916cffad6214 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:46:53 -0500 Subject: [PATCH 057/217] Update .travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 900ba88a..9ae2bfcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,9 @@ before_install: brew install doxygen; nvm install 12.8.0; nvm use 12.8.0; - + elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + choco install nodejs.install --version 12.8.0 + choco install doxygen.install else sudo apt-get update; sudo apt-get install doxygen; From 3bed40f275dacd5541b499000d75a7673d19b2fd Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:47:11 -0500 Subject: [PATCH 058/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ae2bfcc..9dd0de87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: cpp os: - - linux - - osx + #- linux + #- osx - windows compiler: From 3cb0762f2c42f99f95922a23e3613660f2118f3d Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:49:57 -0500 Subject: [PATCH 059/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9dd0de87..cf48324f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ before_install: nvm install 12.8.0; nvm use 12.8.0; elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - choco install nodejs.install --version 12.8.0 + choco install nodejs.install --version 12.8 choco install doxygen.install else sudo apt-get update; From 26be6667ce525755d7b61fcd67f523caba596fad Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:54:41 -0500 Subject: [PATCH 060/217] Update .travis.yml --- .travis.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index cf48324f..459c61ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,14 +15,9 @@ before_install: brew install doxygen; nvm install 12.8.0; nvm use 12.8.0; - elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - choco install nodejs.install --version 12.8 - choco install doxygen.install else - sudo apt-get update; - sudo apt-get install doxygen; - curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -; - sudo apt-get install -y nodejs; + choco install nodejs.install --version 12.8.0 + choco install doxygen.install fi install: travis_retry npm install From 28e7858694145dcde4d218fd62cb0f4ca8b60901 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 11:56:59 -0500 Subject: [PATCH 061/217] Update .travis.yml --- .travis.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 459c61ca..c3ab95dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,8 @@ compiler: # - clang before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update; - brew install doxygen; - nvm install 12.8.0; - nvm use 12.8.0; - else - choco install nodejs.install --version 12.8.0 - choco install doxygen.install - fi + - choco install nodejs.install --version 12.8.0 + - choco install doxygen.install install: travis_retry npm install From 37233679f3192bfd53718689febfd2f664fd37c3 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:02:14 -0500 Subject: [PATCH 062/217] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c3ab95dc..ba30a557 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,9 @@ compiler: # - clang before_install: - - choco install nodejs.install --version 12.8.0 - - choco install doxygen.install + #- choco install -y nodejs.install --version 12.8.0 + - choco install -y --force nodejs@v12.8.0 + - choco install -y doxygen.install install: travis_retry npm install From c5113ace264f62aa7f9cb8ad9c657a9d05444ee2 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:04:14 -0500 Subject: [PATCH 063/217] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ba30a557..7f956bee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,9 @@ compiler: # - clang before_install: - #- choco install -y nodejs.install --version 12.8.0 - - choco install -y --force nodejs@v12.8.0 + - choco install -y nodejs.install --version 12.8.0 + - npm i -g npm + #- choco install -y --force nodejs@v12.8.0 - choco install -y doxygen.install install: travis_retry npm install From 8ed838b3f982a1e96d9a02ba7b87debc973db9bb Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:06:25 -0500 Subject: [PATCH 064/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7f956bee..5f9de628 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ compiler: before_install: - choco install -y nodejs.install --version 12.8.0 - - npm i -g npm #- choco install -y --force nodejs@v12.8.0 + #- npm i -g npm - choco install -y doxygen.install install: travis_retry npm install From 1062a72a490800470fb51c97a66c6481324ffa73 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:45:48 -0500 Subject: [PATCH 065/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5f9de628..d61d6a38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_install: #- choco install -y --force nodejs@v12.8.0 #- npm i -g npm - choco install -y doxygen.install + - refreshenv install: travis_retry npm install From 82178ab2074dcce64404ed2d9f398d4a4e018038 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:50:12 -0500 Subject: [PATCH 066/217] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d61d6a38..397bff19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,8 @@ before_install: #- choco install -y --force nodejs@v12.8.0 #- npm i -g npm - choco install -y doxygen.install - - refreshenv + - node --version + - npm --version install: travis_retry npm install From 120bf26d4c63ffa347a1df4253800236d9609c7c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 12:54:42 -0500 Subject: [PATCH 067/217] Update .travis.yml --- .travis.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 397bff19..55e9111a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,7 @@ -language: cpp +#language: cpp +language: node_js +node_js: + - '12.8.0' os: #- linux @@ -10,12 +13,12 @@ compiler: # - clang before_install: - - choco install -y nodejs.install --version 12.8.0 + #- choco install -y nodejs.install --version 12.8.0 #- choco install -y --force nodejs@v12.8.0 #- npm i -g npm - - choco install -y doxygen.install + #- choco install -y doxygen.install - node --version - - npm --version + #- npm --version install: travis_retry npm install From af216f280cc5833e36fa27d30fb7e30440919779 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:05:16 -0500 Subject: [PATCH 068/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 55e9111a..5e3f4ff9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ before_install: #- choco install -y --force nodejs@v12.8.0 #- npm i -g npm #- choco install -y doxygen.install + - choco install -y make - node --version #- npm --version From 6a0827108d7228aa10bac56b21d29801b32ffff1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:17:44 -0500 Subject: [PATCH 069/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e3f4ff9..fc763bf7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ before_install: #- choco install -y nodejs.install --version 12.8.0 #- choco install -y --force nodejs@v12.8.0 #- npm i -g npm - #- choco install -y doxygen.install - choco install -y make - node --version + - choco install -y doxygen.install #- npm --version install: travis_retry npm install From 499129b863516a71bf94a679c18e72e210daa4e6 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:28:08 -0500 Subject: [PATCH 070/217] Update .travis.yml --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc763bf7..97ad1be6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,11 +24,12 @@ before_install: install: travis_retry npm install script: - - node --version - - cmake ./ - - make - - ./bin/amo_tools_suite_tests - - npm install - - npm run test - - npm run at - - doxygen Doxyfile.in + - ls + #- node --version + #- cmake ./ + #- make + #- ./bin/amo_tools_suite_tests + #- npm install + #- npm run test + #- npm run at + #- doxygen Doxyfile.in From 80defc4470eb4ae8e0689bef035f69ae2d3b6a83 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:33:18 -0500 Subject: [PATCH 071/217] Update .travis.yml --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97ad1be6..39014156 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,9 +24,10 @@ before_install: install: travis_retry npm install script: - - ls - #- node --version - #- cmake ./ + - ls -a + - node --version + - cmake ./ + - ls -a #- make #- ./bin/amo_tools_suite_tests #- npm install From 27bc81bf0795de1db2269398d78ccc1e7eabd353 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:55:10 -0500 Subject: [PATCH 072/217] Update .travis.yml --- .travis.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39014156..11094684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,9 +25,15 @@ install: travis_retry npm install script: - ls -a - - node --version - - cmake ./ - - ls -a + - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ + - cmake --build . + - ./bin/amo_tools_suite_tests + - npm install + - node-gyp rebuild + - npm run test + - npm run at + #- node --version + #- cmake ./ #- make #- ./bin/amo_tools_suite_tests #- npm install From 101bcc62cd5e6e2558f3773079ce3c16e39d7ee1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:59:39 -0500 Subject: [PATCH 073/217] Update .travis.yml --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 11094684..d64b5e11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,9 +27,11 @@ script: - ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - cmake --build . - - ./bin/amo_tools_suite_tests + - ls -a + #- ./bin/amo_tools_suite_tests + - ./Debug/amo_tools_suite_tests - npm install - - node-gyp rebuild + #- node-gyp rebuild - npm run test - npm run at #- node --version From 3c11712f1b2364d9c0c12c490a67e6ea4fd898af Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 14:10:54 -0500 Subject: [PATCH 074/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d64b5e11..3c2c67f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,7 @@ script: #- node-gyp rebuild - npm run test - npm run at + - doxygen Doxyfile.in #- node --version #- cmake ./ #- make From 253b5248d25b99f0e94f1fa4dea47090c931d5f5 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:00:20 -0500 Subject: [PATCH 075/217] Update .travis.yml --- .travis.yml | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c2c67f9..3a2b83fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ node_js: - '12.8.0' os: - #- linux - #- osx + - linux + - osx - windows compiler: @@ -13,13 +13,25 @@ compiler: # - clang before_install: - #- choco install -y nodejs.install --version 12.8.0 - #- choco install -y --force nodejs@v12.8.0 - #- npm i -g npm - - choco install -y make + - | + if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update + sudo apt-get install -y make + sudo apt-get install -y doxygen + fi + - | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + choco install -y make + choco install -y doxygen.install + fi + - | + if [[ $TRAVIS_OS_NAME == "mac" ]]; then + bew update + brew install -y make + brew install -y doxygen + fi + - node --version - - choco install -y doxygen.install - #- npm --version install: travis_retry npm install @@ -28,8 +40,12 @@ script: - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - cmake --build . - ls -a - #- ./bin/amo_tools_suite_tests - - ./Debug/amo_tools_suite_tests + - | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ./Debug/amo_tools_suite_tests + else + ./bin/amo_tools_suite_tests + fi - npm install #- node-gyp rebuild - npm run test From 9df2d90ba4c93ff5920ec17312be8f31fa80c074 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:11:28 -0500 Subject: [PATCH 076/217] Update .travis.yml --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a2b83fa..be581921 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,12 @@ script: #- node-gyp rebuild - npm run test - npm run at - - doxygen Doxyfile.in + - | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + echo "Skipping Doxygen" + else + - doxygen Doxyfile.in + fi #- node --version #- cmake ./ #- make From 28a5585b67c26084518835b35168e4231797f1b1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:19:44 -0500 Subject: [PATCH 077/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index be581921..779c087b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ before_install: fi - node --version + - doxygen --version install: travis_retry npm install From fb6d03751a0dbe3f81df6fade12dbafe676337d2 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:24:58 -0500 Subject: [PATCH 078/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 779c087b..c1b592ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ before_install: choco install -y doxygen.install fi - | - if [[ $TRAVIS_OS_NAME == "mac" ]]; then + if [[ $TRAVIS_OS_NAME == "osx" ]]; then bew update brew install -y make brew install -y doxygen From db70d82f90aa07ad1396bcee370c6befeac3df91 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:29:04 -0500 Subject: [PATCH 079/217] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c1b592ce..f0acddb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ node_js: - '12.8.0' os: - - linux - - osx + #- linux + #- osx - windows compiler: @@ -22,7 +22,7 @@ before_install: - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install -y make - choco install -y doxygen.install + choco install -y doxygen fi - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then From e2222a9614f325edcedae5a93d09738786206d63 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:31:14 -0500 Subject: [PATCH 080/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f0acddb4..ec72f5cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ before_install: if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get update sudo apt-get install -y make - sudo apt-get install -y doxygen + sudo apt-get install -y doxygen.portable fi - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then From 07b7aa769f2f808ce60dbce06cb2823335281406 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:36:00 -0500 Subject: [PATCH 081/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec72f5cb..f646ee4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,12 +17,12 @@ before_install: if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get update sudo apt-get install -y make - sudo apt-get install -y doxygen.portable + sudo apt-get install -y doxygen fi - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install -y make - choco install -y doxygen + choco install -y doxygen.install fi - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then From 2bdeca5921b5e82311201f5b815f24f2abcce249 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:38:05 -0500 Subject: [PATCH 082/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f646ee4b..86218a0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_install: - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install -y make - choco install -y doxygen.install + choco install -y doxygen.portable fi - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then From 6d3072d69810f7b7489c3243260a778278c34461 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:40:31 -0500 Subject: [PATCH 083/217] Update .travis.yml --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86218a0a..85d3cece 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ node_js: - '12.8.0' os: - #- linux - #- osx + - linux + - osx - windows compiler: @@ -32,7 +32,7 @@ before_install: fi - node --version - - doxygen --version + #- doxygen --version install: travis_retry npm install @@ -55,7 +55,7 @@ script: if [[ $TRAVIS_OS_NAME == "windows" ]]; then echo "Skipping Doxygen" else - - doxygen Doxyfile.in + doxygen Doxyfile.in fi #- node --version #- cmake ./ From 11b1c8a18921a8b361789b36fcde705af9e0d34e Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:43:48 -0500 Subject: [PATCH 084/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 85d3cece..fddf8b32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ before_install: - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install -y make - choco install -y doxygen.portable + choco install -y doxygen.install fi - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then From 405a897c2609539259e9d7db6ac083aec3b8eb85 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:50:27 -0500 Subject: [PATCH 085/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fddf8b32..9630dd2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,8 @@ before_install: - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then bew update - brew install -y make - brew install -y doxygen + brew install make + brew install doxygen fi - node --version From 993a5217df53cb2c7da426afa353154f640abee6 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Wed, 4 Mar 2020 15:52:25 -0500 Subject: [PATCH 086/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9630dd2c..77e21100 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,8 @@ before_install: fi - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then - choco install -y make - choco install -y doxygen.install + choco install make --yes + choco install doxygen.install --yes fi - | if [[ $TRAVIS_OS_NAME == "osx" ]]; then From 40619e6034116d67a1bf7c47c4db948d477d1cea Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 09:02:49 -0500 Subject: [PATCH 087/217] Update .travis.yml --- .travis.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77e21100..fbeb931e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,9 +34,12 @@ before_install: - node --version #- doxygen --version -install: travis_retry npm install +install: + - travis_retry npm install + #- node-gyp rebuild script: + if: branch = master - ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - cmake --build . @@ -47,8 +50,6 @@ script: else ./bin/amo_tools_suite_tests fi - - npm install - #- node-gyp rebuild - npm run test - npm run at - | @@ -57,11 +58,3 @@ script: else doxygen Doxyfile.in fi - #- node --version - #- cmake ./ - #- make - #- ./bin/amo_tools_suite_tests - #- npm install - #- npm run test - #- npm run at - #- doxygen Doxyfile.in From cc858e21f2176032b39b6b3160ce513d29958352 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 09:14:16 -0500 Subject: [PATCH 088/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fbeb931e..4e89af89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ install: #- node-gyp rebuild script: - if: branch = master + - if: branch = "master" - ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - cmake --build . From d92a015756b8638e7d15a098d2285d7cfaf7e690 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 09:56:57 -0500 Subject: [PATCH 089/217] Update .travis.yml --- .travis.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e89af89..a85713bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,21 @@ language: node_js node_js: - '12.8.0' - -os: - - linux - - osx - - windows - + compiler: - gcc -# - clang + #- clang + +matrix: + include: + - name: "Linux Build" + os: linux + + - name: "Mac Build" + os: osx + + - name: "Windows Build" + os: windows before_install: - | From f611c4744162903a1a8765c41335fc2a04d0fb1f Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 10:18:47 -0500 Subject: [PATCH 090/217] Update .travis.yml --- .travis.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a85713bc..bf3b0c53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,10 @@ matrix: os: windows before_install: + - | + if [[ $TRAVIS_BRANCH == "master" ]]; then + export PRODUCTION="master" + fi - | if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get update @@ -45,14 +49,19 @@ install: #- node-gyp rebuild script: - - if: branch = "master" + - | + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + export PACKAGE="ON" + else + export PACKAGE="OFF" + fi - ls -a - - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ + - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE --config Release ./ - cmake --build . - ls -a - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ./Debug/amo_tools_suite_tests + ./Release/amo_tools_suite_tests else ./bin/amo_tools_suite_tests fi @@ -64,3 +73,8 @@ script: else doxygen Doxyfile.in fi + - | + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + make package + fi + - ls From 7f0ca3b8e1e31d8fdf0b8689faff6cc4f34bfaa8 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 10:28:32 -0500 Subject: [PATCH 091/217] Update .travis.yml --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf3b0c53..13954416 100644 --- a/.travis.yml +++ b/.travis.yml @@ -73,8 +73,8 @@ script: else doxygen Doxyfile.in fi - - | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - make package - fi - - ls + - | + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + make package + fi + - ls From df6fe0a72d571ce3fb859cb9e56aa6d0c0711842 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 10:42:29 -0500 Subject: [PATCH 092/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13954416..dd2c8e74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,8 +56,8 @@ script: export PACKAGE="OFF" fi - ls -a - - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE --config Release ./ - - cmake --build . + - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ + - cmake --build . --config Release - ls -a - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then From 02ca897a7dceea11b707d320ea64d2c72312dff7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 5 Mar 2020 10:56:17 -0500 Subject: [PATCH 093/217] Added release deployment to Travis CI --- .travis.yml | 140 +++++++++++++++++++++++++--------------------------- 1 file changed, 68 insertions(+), 72 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd2c8e74..d7836bcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,80 +1,76 @@ -#language: cpp language: node_js node_js: - - '12.8.0' - +- 12.8.0 compiler: - - gcc - #- clang - +- gcc matrix: include: - - name: "Linux Build" - os: linux - - - name: "Mac Build" - os: osx - - - name: "Windows Build" - os: windows - + - name: Linux Build + os: linux + - name: Mac Build + os: osx + - name: Windows Build + os: windows before_install: - - | - if [[ $TRAVIS_BRANCH == "master" ]]; then - export PRODUCTION="master" - fi - - | - if [[ $TRAVIS_OS_NAME == "linux" ]]; then - sudo apt-get update - sudo apt-get install -y make - sudo apt-get install -y doxygen - fi - - | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - choco install make --yes - choco install doxygen.install --yes - fi - - | - if [[ $TRAVIS_OS_NAME == "osx" ]]; then - bew update - brew install make - brew install doxygen - fi - - - node --version - #- doxygen --version - +- | + if [[ $TRAVIS_BRANCH == "master" ]]; then + export PRODUCTION="master" + fi +- | + if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update + sudo apt-get install -y make + sudo apt-get install -y doxygen + fi +- | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + choco install make --yes + choco install doxygen.install --yes + fi +- | + if [[ $TRAVIS_OS_NAME == "osx" ]]; then + bew update + brew install make + brew install doxygen + fi +- node --version install: - - travis_retry npm install - #- node-gyp rebuild - +- travis_retry npm install script: - - | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - export PACKAGE="ON" - else - export PACKAGE="OFF" - fi - - ls -a - - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ - - cmake --build . --config Release - - ls -a - - | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ./Release/amo_tools_suite_tests - else - ./bin/amo_tools_suite_tests - fi - - npm run test - - npm run at - - | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - echo "Skipping Doxygen" - else - doxygen Doxyfile.in - fi - - | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - make package - fi - - ls +- | + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + export PACKAGE="ON" + else + export PACKAGE="OFF" + fi +- ls -a +- cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ +- cmake --build . --config Release +- ls -a +- | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ./Release/amo_tools_suite_tests + else + ./bin/amo_tools_suite_tests + fi +- npm run test +- npm run at +- | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + echo "Skipping Doxygen" + else + doxygen Doxyfile.in + fi +- | + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + make package + fi +- ls +deploy: + provider: releases + api_key: + secure: ae/L9wH/mRCWvMQVwoY1qiTT510I/mcbS+OPwBMRtRvP1Svg3klkd7eDxnurIh6bdTgqNdc/Bu1AHXS0xK9pJ27hsJdFsnFaLGZ5kzj4dcH47G9pigEbPKUBHkQzZxn/KikYBvY2M8K+AA39w1In1+V8BE2YPZQYEHwL2g9i0wwqI6xgWl5eUgP1r3Z9+0SNYcWhUsYyx3sYGLwa3E6Sr+/JEHre+qLzHqrdB0PZygxKmjRTeksr3i/tYlAIYaDVXL/xbfewxSuSDYgnz6js5HqdUlpmSDH+aEgPcUopuQOH8utYMBfjKZYpbH3XqcFyPTCQHiJ28FRAi3PnvCZSqdyIkuX6e32GFULbAjJCYpY+pB7Tp89W+/rzOMzZ/H63fDtekfTH+6Q5aDc3WJx1ENh+U7WYHFKu4/qVwDwNfenmUpHR/CGJ/29Waw5+lNVb8RaGl9kiztBOsNAmcsK+qxHPwzIwM/lzlg0fksjoQJ+reNkPJwSpJg6Sn3VvsSKmRGb49qqToYzMsTW4pKhjtyDzaP0g+GxMl/a71KqP9lAxGf9/Auwh1zlp2TsZDOFxLLDFuT24GGto+btdF1TjvzIuym/qwkHac+EPCVm0qGG4+TwSJih7yBd5FL0RNR0VwJW3UQY2PDhv//IvpVF/Pmz8lJJ6AgsUumtYU5bnw+U= + file: '"File_To_Upload"' + on: + repo: ORNL-AMO/AMO-Tools-Suite + branch: issue-480 From 677cda7b7be6e69cbe928b13fb60b786467c5f01 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 10:58:45 -0500 Subject: [PATCH 094/217] Update .travis.yml --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7836bcb..9beddece 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,10 +43,10 @@ script: else export PACKAGE="OFF" fi -- ls -a +#- ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ - cmake --build . --config Release -- ls -a +#- ls -a - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then ./Release/amo_tools_suite_tests @@ -65,7 +65,8 @@ script: if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then make package fi -- ls +- ls -a + deploy: provider: releases api_key: From 877bc5d5e2548c00f9f4e900176321f981135b43 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:05:46 -0500 Subject: [PATCH 095/217] Update .travis.yml --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9beddece..292b3ff8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,15 @@ deploy: provider: releases api_key: secure: ae/L9wH/mRCWvMQVwoY1qiTT510I/mcbS+OPwBMRtRvP1Svg3klkd7eDxnurIh6bdTgqNdc/Bu1AHXS0xK9pJ27hsJdFsnFaLGZ5kzj4dcH47G9pigEbPKUBHkQzZxn/KikYBvY2M8K+AA39w1In1+V8BE2YPZQYEHwL2g9i0wwqI6xgWl5eUgP1r3Z9+0SNYcWhUsYyx3sYGLwa3E6Sr+/JEHre+qLzHqrdB0PZygxKmjRTeksr3i/tYlAIYaDVXL/xbfewxSuSDYgnz6js5HqdUlpmSDH+aEgPcUopuQOH8utYMBfjKZYpbH3XqcFyPTCQHiJ28FRAi3PnvCZSqdyIkuX6e32GFULbAjJCYpY+pB7Tp89W+/rzOMzZ/H63fDtekfTH+6Q5aDc3WJx1ENh+U7WYHFKu4/qVwDwNfenmUpHR/CGJ/29Waw5+lNVb8RaGl9kiztBOsNAmcsK+qxHPwzIwM/lzlg0fksjoQJ+reNkPJwSpJg6Sn3VvsSKmRGb49qqToYzMsTW4pKhjtyDzaP0g+GxMl/a71KqP9lAxGf9/Auwh1zlp2TsZDOFxLLDFuT24GGto+btdF1TjvzIuym/qwkHac+EPCVm0qGG4+TwSJih7yBd5FL0RNR0VwJW3UQY2PDhv//IvpVF/Pmz8lJJ6AgsUumtYU5bnw+U= - file: '"File_To_Upload"' + file: + - "File_To_Upload" + overwrite: true + skip_cleanup: true + draft: true + name: "RELEASE DRAFT" + #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: issue-480 + branch: master + #condition: type = push AND branch = master + #tags: false From 59c1f39e76039ba2f226445e524f567f4db6668d Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:13:23 -0500 Subject: [PATCH 096/217] Update .travis.yml --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 292b3ff8..b379ebc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,7 @@ matrix: - name: Windows Build os: windows before_install: -- | - if [[ $TRAVIS_BRANCH == "master" ]]; then - export PRODUCTION="master" - fi +- export PRODUCTION="master" - | if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get update From ab3e44aa4091ab7f018fa6b5ed06e427149e549f Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:17:50 -0500 Subject: [PATCH 097/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b379ebc0..14fcd652 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ matrix: - name: Windows Build os: windows before_install: -- export PRODUCTION="master" +- export PRODUCTION="issue-480" - | if [[ $TRAVIS_OS_NAME == "linux" ]]; then sudo apt-get update @@ -77,6 +77,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: master + branch: issue-480 #condition: type = push AND branch = master #tags: false From 562b987f71a195918fcc13192bdc50010cd5f59e Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:18:29 -0500 Subject: [PATCH 098/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 14fcd652..44c97205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,6 +77,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: issue-480 + branch: master #condition: type = push AND branch = master #tags: false From 3f6a8a9b705df1be4b7657eda7627c3b9d315641 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:27:55 -0500 Subject: [PATCH 099/217] Update .travis.yml --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 44c97205..4569cf7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,7 +69,11 @@ deploy: api_key: secure: ae/L9wH/mRCWvMQVwoY1qiTT510I/mcbS+OPwBMRtRvP1Svg3klkd7eDxnurIh6bdTgqNdc/Bu1AHXS0xK9pJ27hsJdFsnFaLGZ5kzj4dcH47G9pigEbPKUBHkQzZxn/KikYBvY2M8K+AA39w1In1+V8BE2YPZQYEHwL2g9i0wwqI6xgWl5eUgP1r3Z9+0SNYcWhUsYyx3sYGLwa3E6Sr+/JEHre+qLzHqrdB0PZygxKmjRTeksr3i/tYlAIYaDVXL/xbfewxSuSDYgnz6js5HqdUlpmSDH+aEgPcUopuQOH8utYMBfjKZYpbH3XqcFyPTCQHiJ28FRAi3PnvCZSqdyIkuX6e32GFULbAjJCYpY+pB7Tp89W+/rzOMzZ/H63fDtekfTH+6Q5aDc3WJx1ENh+U7WYHFKu4/qVwDwNfenmUpHR/CGJ/29Waw5+lNVb8RaGl9kiztBOsNAmcsK+qxHPwzIwM/lzlg0fksjoQJ+reNkPJwSpJg6Sn3VvsSKmRGb49qqToYzMsTW4pKhjtyDzaP0g+GxMl/a71KqP9lAxGf9/Auwh1zlp2TsZDOFxLLDFuT24GGto+btdF1TjvzIuym/qwkHac+EPCVm0qGG4+TwSJih7yBd5FL0RNR0VwJW3UQY2PDhv//IvpVF/Pmz8lJJ6AgsUumtYU5bnw+U= file: - - "File_To_Upload" + - "amo_tools_suite--Linux-x86_64.sh" + - "amo_tools_suite--Linux-x86_64.tar.gz" + - "amo_tools_suite--Darwin-x86_64.sh" + - "amo_tools_suite--Darwin-x86_64.tar.gz" + - "amo_tools_suite--Windows-i386.exe" overwrite: true skip_cleanup: true draft: true From 8486f50df0ad55b2b0a3b49915d4368573a41e86 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:35:25 -0500 Subject: [PATCH 100/217] Update .travis.yml --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4569cf7f..51dd1c74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,11 @@ script: fi - | if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - make package + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + cmake --build . --config Release --target PACKAGE + else + make package + fi fi - ls -a From f4ccfc38df5e7d07dac9ac54534b5c516b6eb538 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:47:25 -0500 Subject: [PATCH 101/217] Update .travis.yml --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51dd1c74..ec9bb166 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,11 +60,8 @@ script: fi - | if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - cmake --build . --config Release --target PACKAGE - else - make package - fi + cmake --build . --config Release --target PACKAGE + #make package fi - ls -a From ccb13ba5729a64fe80135b5e667c00e970a46688 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:49:05 -0500 Subject: [PATCH 102/217] Update .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index ec9bb166..033e87d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ +if: tag IS blank + language: node_js node_js: - 12.8.0 + compiler: - gcc + matrix: include: - name: Linux Build @@ -11,6 +15,7 @@ matrix: os: osx - name: Windows Build os: windows + before_install: - export PRODUCTION="issue-480" - | From f69a234df94025d864d31e1ed1d7855285c493b1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 11:56:03 -0500 Subject: [PATCH 103/217] Update .travis.yml --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 033e87d3..82de135c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,9 +64,11 @@ script: doxygen Doxyfile.in fi - | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + if [ [$TRAVIS_BRANCH == $PRODUCTION] AND NOT [$TRAVIS_OS_NAME == "windows"] ]; then + make package + fi + if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then cmake --build . --config Release --target PACKAGE - #make package fi - ls -a From 7668047b0d232c389256cd753cbef51a2709955b Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 12:10:59 -0500 Subject: [PATCH 104/217] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 82de135c..c04d0a22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,11 +66,12 @@ script: - | if [ [$TRAVIS_BRANCH == $PRODUCTION] AND NOT [$TRAVIS_OS_NAME == "windows"] ]; then make package + ls -a fi if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then cmake --build . --config Release --target PACKAGE + ls -a Release/ fi -- ls -a deploy: provider: releases From 73b0ae7ba6740319985bd4888bfce3c71d4e2db2 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 12:21:57 -0500 Subject: [PATCH 105/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c04d0a22..d6736647 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,6 +68,7 @@ script: make package ls -a fi +- | if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then cmake --build . --config Release --target PACKAGE ls -a Release/ From 7ab613aa00e91320d8e4f609e47ce03b74a64d7d Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 13:04:53 -0500 Subject: [PATCH 106/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d6736647..ecbc7082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ script: doxygen Doxyfile.in fi - | - if [ [$TRAVIS_BRANCH == $PRODUCTION] AND NOT [$TRAVIS_OS_NAME == "windows"] ]; then + if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"] ]; then make package ls -a fi From 913893692944aa2283f6969e1ce9267739e59074 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 13:16:35 -0500 Subject: [PATCH 107/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ecbc7082..91abfe6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,12 +64,12 @@ script: doxygen Doxyfile.in fi - | - if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"] ]; then + if [[$TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME != "windows"]]; then make package ls -a fi - | - if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then + if [[$TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME == "windows"]]; then cmake --build . --config Release --target PACKAGE ls -a Release/ fi From 9d65e9aa4c39ef40dcdb3381c349de65bb441a92 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 13:31:14 -0500 Subject: [PATCH 108/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91abfe6d..8a89a4f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,12 +64,12 @@ script: doxygen Doxyfile.in fi - | - if [[$TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME != "windows"]]; then + if [[ $TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME != "windows" ]]; then make package ls -a fi - | - if [[$TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME == "windows"]]; then + if [[ $TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME == "windows" ]]; then cmake --build . --config Release --target PACKAGE ls -a Release/ fi From 650c75abc7d8c9e760099173baa1f9e3645e7e1c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 13:39:53 -0500 Subject: [PATCH 109/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8a89a4f6..f39ec170 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,12 +64,12 @@ script: doxygen Doxyfile.in fi - | - if [[ $TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME != "windows" ]]; then + if [[ $TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows" ]]; then make package ls -a fi - | - if [[ $TRAVIS_BRANCH == $PRODUCTION AND $TRAVIS_OS_NAME == "windows" ]]; then + if [[ $TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows" ]]; then cmake --build . --config Release --target PACKAGE ls -a Release/ fi From 1e54b94a6158765505d9e7d50d418d4b05d623cb Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 13:52:41 -0500 Subject: [PATCH 110/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f39ec170..e1f19d3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,12 +64,12 @@ script: doxygen Doxyfile.in fi - | - if [[ $TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows" ]]; then + if [[ ($TRAVIS_BRANCH == $PRODUCTION) AND ($TRAVIS_OS_NAME != "windows") ]]; then make package ls -a fi - | - if [[ $TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows" ]]; then + if [[ ($TRAVIS_BRANCH == $PRODUCTION) AND ($TRAVIS_OS_NAME == "windows") ]]; then cmake --build . --config Release --target PACKAGE ls -a Release/ fi From ddaeec3076e34a8401280bbb55c08555e736b2f7 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 14:40:42 -0500 Subject: [PATCH 111/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e1f19d3d..ecbc7082 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,12 +64,12 @@ script: doxygen Doxyfile.in fi - | - if [[ ($TRAVIS_BRANCH == $PRODUCTION) AND ($TRAVIS_OS_NAME != "windows") ]]; then + if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"] ]; then make package ls -a fi - | - if [[ ($TRAVIS_BRANCH == $PRODUCTION) AND ($TRAVIS_OS_NAME == "windows") ]]; then + if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then cmake --build . --config Release --target PACKAGE ls -a Release/ fi From 169dc678d083358da6bb394448daff1fa357d018 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 14:56:19 -0500 Subject: [PATCH 112/217] Update .travis.yml --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index ecbc7082..b16fc75e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,15 +64,11 @@ script: doxygen Doxyfile.in fi - | - if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"] ]; then + if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then make package + #cmake --build . --config Release --target PACKAGE ls -a fi -- | - if [ [$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"] ]; then - cmake --build . --config Release --target PACKAGE - ls -a Release/ - fi deploy: provider: releases From 4e5f74d1e0bc45102a8e5a86f0089b6fbf60f4f0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 5 Mar 2020 15:10:04 -0500 Subject: [PATCH 113/217] Added travis_scripts --- travis_scripts/package_release.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 travis_scripts/package_release.sh diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh new file mode 100644 index 00000000..5ae5fbcf --- /dev/null +++ b/travis_scripts/package_release.sh @@ -0,0 +1,13 @@ +#!/bin/bash + + + +if [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && [$"TRAVIS_OS_NAME" != "windows"] ] +then + make package + ls -a +elif [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && ["$TRAVIS_OS_NAME" == "windows"] ] +then + cmake --build . --config Release --target PACKAGE + ls -a Release/ +fi From 9c46c19cecbb6a452308b3090a4c0cb1634fb035 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:13:57 -0500 Subject: [PATCH 114/217] Update .travis.yml --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b16fc75e..1ef257fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,12 +63,7 @@ script: else doxygen Doxyfile.in fi -- | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - make package - #cmake --build . --config Release --target PACKAGE - ls -a - fi +- bash travis_scripts/package_release.sh deploy: provider: releases From d1f24132b20de5ab156892890850e1a60a4a8ae0 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:22:23 -0500 Subject: [PATCH 115/217] Update package_release.sh --- travis_scripts/package_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 5ae5fbcf..29b9e70b 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -2,7 +2,7 @@ -if [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && [$"TRAVIS_OS_NAME" != "windows"] ] +if [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && ["$TRAVIS_OS_NAME" != "windows"] ] then make package ls -a From 10da05290e46b9b10f0eb5b28457c4833b53440e Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:30:03 -0500 Subject: [PATCH 116/217] Update package_release.sh --- travis_scripts/package_release.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 29b9e70b..3259061e 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,13 +1,13 @@ #!/bin/bash - - -if [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && ["$TRAVIS_OS_NAME" != "windows"] ] +if ["$TRAVIS_BRANCH" == "$PRODUCTION"] then + if ["$TRAVIS_OS_NAME" != "windows"] + then make package ls -a -elif [ ["$TRAVIS_BRANCH" == "$PRODUCTION"] && ["$TRAVIS_OS_NAME" == "windows"] ] -then + else cmake --build . --config Release --target PACKAGE ls -a Release/ + fi fi From 2e3c0106957a53995933302e2914fc9a485537d8 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:38:13 -0500 Subject: [PATCH 117/217] Update package_release.sh --- travis_scripts/package_release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 3259061e..36f582a0 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,8 +1,8 @@ #!/bin/bash -if ["$TRAVIS_BRANCH" == "$PRODUCTION"] +if (("$TRAVIS_BRANCH" == "$PRODUCTION")) then - if ["$TRAVIS_OS_NAME" != "windows"] + if (("$TRAVIS_OS_NAME" != "windows")) then make package ls -a From 0492c7493b849561a399108c1286ba132eb90bed Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:47:16 -0500 Subject: [PATCH 118/217] Update package_release.sh --- travis_scripts/package_release.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 36f582a0..83ad4a86 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -2,12 +2,12 @@ if (("$TRAVIS_BRANCH" == "$PRODUCTION")) then - if (("$TRAVIS_OS_NAME" != "windows")) + if (("$TRAVIS_OS_NAME" == "windows")) then - make package - ls -a - else cmake --build . --config Release --target PACKAGE ls -a Release/ + else + make package + ls -a fi fi From 37e737b986ae6c4ffd19caca58f896cec9113a6c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:48:29 -0500 Subject: [PATCH 119/217] Update package_release.sh --- travis_scripts/package_release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 83ad4a86..04fa9d24 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -5,6 +5,7 @@ then if (("$TRAVIS_OS_NAME" == "windows")) then cmake --build . --config Release --target PACKAGE + ls -a ls -a Release/ else make package From b5360ad0a90e604753fa7ca8d1dcd632fdcbf49d Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 15:59:23 -0500 Subject: [PATCH 120/217] Update package_release.sh --- travis_scripts/package_release.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 04fa9d24..9e01207d 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,5 +1,6 @@ #!/bin/bash + if (("$TRAVIS_BRANCH" == "$PRODUCTION")) then if (("$TRAVIS_OS_NAME" == "windows")) From b6121a4d0a61dabcaf9b557806d0bb27b605f139 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:07:02 -0500 Subject: [PATCH 121/217] Update package_release.sh --- travis_scripts/package_release.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 9e01207d..616a3c8c 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,15 +1,11 @@ #!/bin/bash - if (("$TRAVIS_BRANCH" == "$PRODUCTION")) then if (("$TRAVIS_OS_NAME" == "windows")) then cmake --build . --config Release --target PACKAGE - ls -a - ls -a Release/ else make package - ls -a fi fi From 1bc6e9ac82943a4b0f10d6fcc7046757d67d1497 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:08:40 -0500 Subject: [PATCH 122/217] Update .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1ef257fe..83e99a22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,6 +64,11 @@ script: doxygen Doxyfile.in fi - bash travis_scripts/package_release.sh +ls -a +- | + if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ls -a Release + fi deploy: provider: releases From 9a8c67877d35f82f7c5ed4cc31f9ae0bba49be69 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:09:27 -0500 Subject: [PATCH 123/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 83e99a22..cb9ae72b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ script: doxygen Doxyfile.in fi - bash travis_scripts/package_release.sh -ls -a +- ls -a - | if [[ $TRAVIS_OS_NAME == "windows" ]]; then ls -a Release From a21774282145569213a5a5f8ecda43b17dbd33a4 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:17:51 -0500 Subject: [PATCH 124/217] Update .travis.yml --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb9ae72b..6d2837e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,12 +63,8 @@ script: else doxygen Doxyfile.in fi +- echo "$TRAVIS_OS_NAME" - bash travis_scripts/package_release.sh -- ls -a -- | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ls -a Release - fi deploy: provider: releases From 0ec1b4a05fcb8e85f5f23a3d6fc3dc67bf7381fb Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 5 Mar 2020 16:18:34 -0500 Subject: [PATCH 125/217] Update package_release.sh --- travis_scripts/package_release.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 616a3c8c..a3d02b76 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -5,7 +5,10 @@ then if (("$TRAVIS_OS_NAME" == "windows")) then cmake --build . --config Release --target PACKAGE + ls -a + ls -s Release/ else make package + ls -a fi fi From fc744005b9f7ac48000900fa5a3bb89d1336a463 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 08:44:42 -0500 Subject: [PATCH 126/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6d2837e9..0cc050eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ script: doxygen Doxyfile.in fi - echo "$TRAVIS_OS_NAME" -- bash travis_scripts/package_release.sh +- ./travis_scripts/package_release.sh deploy: provider: releases From f68bcc45eccbadaeca05b79e0c6467669c8e1e19 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 08:50:57 -0500 Subject: [PATCH 127/217] Update package_release.sh --- travis_scripts/package_release.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index a3d02b76..76e3e543 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,14 +1,12 @@ #!/bin/bash -if (("$TRAVIS_BRANCH" == "$PRODUCTION")) +if (("$TRAVIS_BRANCH" == "$PRODUCTION") && ("$TRAVIS_OS_NAME" == "windows")); then - if (("$TRAVIS_OS_NAME" == "windows")) - then - cmake --build . --config Release --target PACKAGE - ls -a - ls -s Release/ - else - make package - ls -a - fi + cmake --build . --config Release --target PACKAGE + ls -a + ls -s Release/ +elif (("$TRAVIS_BRANCH" == "$PRODUCTION") && ("$TRAVIS_OS_NAME" != "windows")); +then + make package + ls -a fi From 0673e2764a5f414a4efcb2b373a3d4dd592cc31b Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 09:09:09 -0500 Subject: [PATCH 128/217] Update package_release.sh --- travis_scripts/package_release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index 76e3e543..a93c7367 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,11 +1,11 @@ #!/bin/bash -if (("$TRAVIS_BRANCH" == "$PRODUCTION") && ("$TRAVIS_OS_NAME" == "windows")); +if [["$TRAVIS_BRANCH" == "$PRODUCTION" && "$TRAVIS_OS_NAME" == "windows"]]; then cmake --build . --config Release --target PACKAGE ls -a ls -s Release/ -elif (("$TRAVIS_BRANCH" == "$PRODUCTION") && ("$TRAVIS_OS_NAME" != "windows")); +elif [["$TRAVIS_BRANCH" == "$PRODUCTION" && "$TRAVIS_OS_NAME" != "windows"]]; then make package ls -a From 3b8d2286660c62e2090cf41ae7c14e22040955ea Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 09:10:03 -0500 Subject: [PATCH 129/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0cc050eb..6d2837e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ script: doxygen Doxyfile.in fi - echo "$TRAVIS_OS_NAME" -- ./travis_scripts/package_release.sh +- bash travis_scripts/package_release.sh deploy: provider: releases From dc0955a62c8773d894ee5dcc38a8045302b13213 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 10:57:13 -0500 Subject: [PATCH 130/217] Update .travis.yml --- .travis.yml | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d2837e9..3f950e78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,50 +18,44 @@ matrix: before_install: - export PRODUCTION="issue-480" -- | - if [[ $TRAVIS_OS_NAME == "linux" ]]; then - sudo apt-get update - sudo apt-get install -y make - sudo apt-get install -y doxygen +- if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update; + sudo apt-get install -y make; + sudo apt-get install -y doxygen; fi -- | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - choco install make --yes - choco install doxygen.install --yes +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then + choco install make --yes; + choco install doxygen.install --yes; fi -- | - if [[ $TRAVIS_OS_NAME == "osx" ]]; then - bew update - brew install make - brew install doxygen +- if [[ $TRAVIS_OS_NAME == "osx" ]]; then + bew update; + brew install make; + brew install doxygen; fi - node --version install: - travis_retry npm install script: -- | - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - export PACKAGE="ON" +- if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + export PACKAGE="ON"; else - export PACKAGE="OFF" + export PACKAGE="OFF"; fi #- ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ - cmake --build . --config Release #- ls -a -- | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ./Release/amo_tools_suite_tests +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ./Release/amo_tools_suite_tests; else - ./bin/amo_tools_suite_tests + ./bin/amo_tools_suite_tests; fi - npm run test - npm run at -- | - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - echo "Skipping Doxygen" +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then + echo "Skipping Doxygen"; else - doxygen Doxyfile.in + doxygen Doxyfile.in; fi - echo "$TRAVIS_OS_NAME" - bash travis_scripts/package_release.sh From 883393fae88254e97d811a0feef2934b89a65faa Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 11:10:08 -0500 Subject: [PATCH 131/217] Update .travis.yml --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f950e78..aad62c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,8 +57,16 @@ script: else doxygen Doxyfile.in; fi -- echo "$TRAVIS_OS_NAME" -- bash travis_scripts/package_release.sh +#- echo "$TRAVIS_OS_NAME" +#- bash travis_scripts/package_release.sh +- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"]]; + cmake --build . --config Release --target PACKAGE; + ls -a + ls -a Release/ + elif [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; + make package + ls -a + fi deploy: provider: releases From b6afd1dc30831479ce8a246766d7a9fd8e6c802c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 11:17:01 -0500 Subject: [PATCH 132/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index aad62c51..2e15942a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,11 +59,11 @@ script: fi #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"]]; +- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"]]; then cmake --build . --config Release --target PACKAGE; ls -a ls -a Release/ - elif [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; + elif [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; then make package ls -a fi From 7a7134bc22a20dfcb8ab7ddda284f5e5fee1c536 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 6 Mar 2020 11:27:00 -0500 Subject: [PATCH 133/217] Removed Docker files --- Docker/.git_keep | 0 Docker/Dockerfile | 145 ------------------------------------- Docker/docker_commands.txt | 36 --------- 3 files changed, 181 deletions(-) create mode 100644 Docker/.git_keep delete mode 100644 Docker/Dockerfile delete mode 100644 Docker/docker_commands.txt diff --git a/Docker/.git_keep b/Docker/.git_keep new file mode 100644 index 00000000..e69de29b diff --git a/Docker/Dockerfile b/Docker/Dockerfile deleted file mode 100644 index ae3d5b6a..00000000 --- a/Docker/Dockerfile +++ /dev/null @@ -1,145 +0,0 @@ -FROM ubuntu:18.04 - -WORKDIR /home/ - -RUN apt -y update -RUN apt -y upgrade - -# Install gcc -RUN apt -y install build-essential -RUN apt-get -y install manpages-dev -RUN gcc --version - -# Install Python -RUN apt-get -y install python -RUN python --version - -# Install curl -RUN apt -y install curl - -# Install cmake -RUN apt -y install cmake -RUN cmake --version - -# Install ccmake -RUN apt -y install cmake-curses-gui -RUN ccmake --version - -# Install Doxygen -RUN apt -y install doxygen -RUN doxygen --version - -# -------------------------------------------------------------------------------------------- - -# Install nvm, node and npm -#RUN touch ~/.bash_profile -#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash -# replace shell with bash so we can source files -#RUN rm /bin/sh && ln -s /bin/bash /bin/sh -#RUN source ~/.nvm/nvm.sh \ nvm --version -#RUN export NVM_DIR="$HOME/.nvm" -#RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -#RUN [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion -#RUN nvm --version - - - -# replace shell with bash so we can source files -RUN rm /bin/sh && ln -s /bin/bash /bin/sh - -# update the repository sources list -# and install dependencies -RUN apt-get update \ - && apt-get install -y curl \ - && apt-get -y autoclean - -# nvm environment variables -ENV NVM_DIR /usr/local/nvm -ENV NODE_VERSION 12.8.0 - -# install nvm -# https://github.com/creationix/nvm#install-script -RUN curl --silent -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash - -# install node and npm -RUN source $NVM_DIR/nvm.sh \ - && nvm install $NODE_VERSION \ - && nvm alias default $NODE_VERSION \ - && nvm use default - -# add node and npm to path so the commands are available -ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules -ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH - -# confirm installation -RUN node -v -RUN npm -v -# --------------------------------------------------------------------------------------------- - -# --------------------------------------------------------------------------------------------- -# This section is currently inactive - -# Install node.js and npm (https://github.com/nodesource/distributions/blob/master/README.md) -#RUN nvm install node -#RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - -#RUN apt-get install -y nodejs -#RUN node --version -#RUN npm --version - -# Install npm -#RUN apt -y install npm -#RUN npm --version -# --------------------------------------------------------------------------------------------- - -# Install gyp -RUN npm install -g node-gyp@4.0.0 -RUN node-gyp -v - - -# Add AMO-Tools-Suite -RUN mkdir AMO -RUN mkdir AMO/AMO-Tools-Suite -# Inside AMO-Tools-Suite directory -ADD . /home/AMO/AMO-Tools-Suite/ - - -#RUN touch package.json -WORKDIR /home/AMO/AMO-Tools-Suite/ - -# Install Node Tap (test suite) -# @12.6.0, --save-dev -RUN npm install tap@12.6.0 --save-dev -#RUN apt -y install node-tap -#RUN tap --version - -WORKDIR /home/ - -# Install emacs -RUN apt-get -y install emacs -RUN emacs --version - -# Install sqlite3 -RUN apt-get install sqlite3 libsqlite3-dev -RUN sqlite3 --version - - -# Commands to run for building/testing/running AMO-Tools-Suite -# ------------------------------------------------------------- -WORKDIR /home/AMO/AMO-Tools-Suite/ - -RUN cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ - -RUN cmake --build . - -RUN ./bin/amo_tools_suite_tests - -RUN npm install - -RUN node-gyp rebuild - -RUN npm run test - -RUN npm run at -#-------------------------------------------------------------- - -#WORKDIR /home/ diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt deleted file mode 100644 index f88030e2..00000000 --- a/Docker/docker_commands.txt +++ /dev/null @@ -1,36 +0,0 @@ -docker image build -f Docker/Dockerfile -t comma64/ornl:issue-469 . -docker run -t -d --name amo-suite comma64/ornl:issue-469 -docker exec -it amo-suite /bin/bash -docker container rm --force amo-suite - -docker login -docker push comma64/ornl:issue-469 - - - -docker stop $(docker ps -aq) 2>/dev/null || true -docker rm $(docker ps -a -q) 2>/dev/null|| true -docker rmi $(docker images -q) 2>/dev/null || true -docker image prune -fa || sudo systemctl restart docker -docker system prune -fa || sudo systemctl restart docker - - -# Commands to run for building/testing/running AMO-Tools-Suite -# ------------------------------------------------------------- - -cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ -alternatively: ccmake . - -cmake --build . --target amo_tools_suite_tests -alternatively: cmake --build . - -./bin/amo_tools_suite_tests - -npm install (OR (if necessary): npm install --unsafe-perm) -alternatively (if already installed): node-gyp rebuild - -npm run test - -npm run at -#-------------------------------------------------------------- - From 03f7110422b34af050788a78c7fb7ed437e1ec67 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 11:35:51 -0500 Subject: [PATCH 134/217] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2e15942a..ef281b9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,8 @@ script: cmake --build . --config Release --target PACKAGE; ls -a ls -a Release/ - elif [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; then + fi +- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; then make package ls -a fi From d42e63a56be44322fdf8b0efd96904674a0d3cd2 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 11:55:35 -0500 Subject: [PATCH 135/217] Update .travis.yml --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef281b9f..ea6736c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,12 +61,12 @@ script: #- bash travis_scripts/package_release.sh - if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"]]; then cmake --build . --config Release --target PACKAGE; - ls -a - ls -a Release/ + ls -a; + ls -a Release/; fi - if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; then - make package - ls -a + make package; + ls -a; fi deploy: From 87491d3c1a7ee66584e6896882bd7b1fee040e0e Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 12:05:21 -0500 Subject: [PATCH 136/217] Update .travis.yml --- .travis.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index ea6736c1..d5821659 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,15 +59,8 @@ script: fi #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME == "windows"]]; then - cmake --build . --config Release --target PACKAGE; - ls -a; - ls -a Release/; - fi -- if [[$TRAVIS_BRANCH == $PRODUCTION] AND [$TRAVIS_OS_NAME != "windows"]]; then - make package; - ls -a; - fi +- make package +- ls -a deploy: provider: releases From 8ec87fe872db2c4f060a15e854f33ea599b0ad18 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 12:49:33 -0500 Subject: [PATCH 137/217] Update .travis.yml --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d5821659..c1bf9224 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,8 +59,12 @@ script: fi #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -- make package + +#- make package +#- ls -a +- cmake --build . --config Release --target PACKAGE - ls -a +- ls -a Release/ deploy: provider: releases From 97621db30dd2cb1134443a6e9b4a715a8c21cb6a Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:02:17 -0500 Subject: [PATCH 138/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index c1bf9224..b3f33a53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_install: - if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make --yes; choco install doxygen.install --yes; + choco install visualstudio2017buildtools --yes; fi - if [[ $TRAVIS_OS_NAME == "osx" ]]; then bew update; From 59ee2d140fc3e7572710385f2c474638ec14cfa3 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:15:37 -0500 Subject: [PATCH 139/217] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b3f33a53..48e64e9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,7 @@ before_install: choco install make --yes; choco install doxygen.install --yes; choco install visualstudio2017buildtools --yes; + choco install nsis --yes; fi - if [[ $TRAVIS_OS_NAME == "osx" ]]; then bew update; From b54724b5b6f655bab256bb6939010b70b98855ec Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:27:49 -0500 Subject: [PATCH 140/217] Update .travis.yml --- .travis.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 48e64e9d..b32337d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,11 +62,14 @@ script: #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -#- make package -#- ls -a -- cmake --build . --config Release --target PACKAGE +- if [[ $TRAVIS_OS_NAME == "windows" ]]; then + cmake --build . --config Release --target PACKAGE + else + make package + fi + - ls -a -- ls -a Release/ +#- ls -a Release/ deploy: provider: releases From a987b283527a46cd2aba8145a8d18400603bfcf2 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:35:17 -0500 Subject: [PATCH 141/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b32337d4..3d0b626e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,9 +63,9 @@ script: #- bash travis_scripts/package_release.sh - if [[ $TRAVIS_OS_NAME == "windows" ]]; then - cmake --build . --config Release --target PACKAGE + cmake --build . --config Release --target PACKAGE; else - make package + make package; fi - ls -a From 8b2a2c9027e893fd5c1753c3ed0a7d7b76853a65 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:54:32 -0500 Subject: [PATCH 142/217] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3d0b626e..2dde65fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,9 +62,10 @@ script: #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -- if [[ $TRAVIS_OS_NAME == "windows" ]]; then +- if [ [$TRAVIS_OS_NAME == "windows"] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then cmake --build . --config Release --target PACKAGE; - else + fi +- if [ [$TRAVIS_OS_NAME != "windows"] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then make package; fi From bcc2f5a74437486106dabe620a5aa36c2f61332b Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 13:59:01 -0500 Subject: [PATCH 143/217] Update .travis.yml --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2dde65fa..389c1b78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,7 +71,15 @@ script: - ls -a #- ls -a Release/ - +before_deploy: + #function keep_alive() { + # while true; do + # echo -en "\a" + # sleep 5 + # done + #} + #keep_alive & + - export TRAVIS_TAG="release_draft" deploy: provider: releases api_key: From ddde6181e653ad35999c05e02eecaa01d04ac7c6 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 14:03:33 -0500 Subject: [PATCH 144/217] Update .travis.yml --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 389c1b78..c37a4015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,13 +61,9 @@ script: fi #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh +- if [ [$TRAVIS_OS_NAME == 'windows'] OR [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry cmake --build . --config Release --target PACKAGE; fi -- if [ [$TRAVIS_OS_NAME == "windows"] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then - cmake --build . --config Release --target PACKAGE; - fi -- if [ [$TRAVIS_OS_NAME != "windows"] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then - make package; - fi +- if [ [$TRAVIS_OS_NAME != 'windows'] OR [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry make package; fi - ls -a #- ls -a Release/ From 94a7a4ba24ee6bae867f9e5ef1f7f3c4ffb10c97 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Fri, 6 Mar 2020 14:06:02 -0500 Subject: [PATCH 145/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c37a4015..c62b0461 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,9 +61,9 @@ script: fi #- echo "$TRAVIS_OS_NAME" #- bash travis_scripts/package_release.sh -- if [ [$TRAVIS_OS_NAME == 'windows'] OR [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry cmake --build . --config Release --target PACKAGE; fi +- if [ [$TRAVIS_OS_NAME == 'windows'] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry cmake --build . --config Release --target PACKAGE; fi -- if [ [$TRAVIS_OS_NAME != 'windows'] OR [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry make package; fi +- if [ [$TRAVIS_OS_NAME != 'windows'] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry make package; fi - ls -a #- ls -a Release/ From 82b90125305432c7b07076612d3921754beac2d5 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 11:28:19 -0400 Subject: [PATCH 146/217] Update package_release.sh --- travis_scripts/package_release.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/travis_scripts/package_release.sh b/travis_scripts/package_release.sh index a93c7367..df3eda0d 100644 --- a/travis_scripts/package_release.sh +++ b/travis_scripts/package_release.sh @@ -1,12 +1,16 @@ #!/bin/bash -if [["$TRAVIS_BRANCH" == "$PRODUCTION" && "$TRAVIS_OS_NAME" == "windows"]]; +set -ev + +if [[ $TRAVIS_OS_NAME == "linux" ]] +then + export OS_FLAG="l"; +elif [[ $TRAVIS_OS_NAME == "osx" ]] then - cmake --build . --config Release --target PACKAGE - ls -a - ls -s Release/ -elif [["$TRAVIS_BRANCH" == "$PRODUCTION" && "$TRAVIS_OS_NAME" != "windows"]]; + export OS_FLAG="m"; +elif [[ $TRAVIS_OS_NAME == "windows" ]] then - make package - ls -a + export OS_FLAG="w"; fi + +exit 0; From fc2d2524e0f97da91ea0ee433291b5e0f7894023 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 9 Mar 2020 11:32:38 -0400 Subject: [PATCH 147/217] Added scripts travis_scripts/ --- travis_scripts/before_install.sh | 0 travis_scripts/build.sh | 0 travis_scripts/{package_release.sh => get_os.sh} | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 travis_scripts/before_install.sh create mode 100644 travis_scripts/build.sh rename travis_scripts/{package_release.sh => get_os.sh} (100%) diff --git a/travis_scripts/before_install.sh b/travis_scripts/before_install.sh new file mode 100644 index 00000000..e69de29b diff --git a/travis_scripts/build.sh b/travis_scripts/build.sh new file mode 100644 index 00000000..e69de29b diff --git a/travis_scripts/package_release.sh b/travis_scripts/get_os.sh similarity index 100% rename from travis_scripts/package_release.sh rename to travis_scripts/get_os.sh From a4ed5591d24d75e8a18ff59290f827898574cbba Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 11:36:11 -0400 Subject: [PATCH 148/217] Update before_install.sh --- travis_scripts/before_install.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/travis_scripts/before_install.sh b/travis_scripts/before_install.sh index e69de29b..db43dc03 100644 --- a/travis_scripts/before_install.sh +++ b/travis_scripts/before_install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -ev + +if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update; + sudo apt-get install -y make; + sudo apt-get install -y doxygen; +fi +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + choco install make --yes; + choco install doxygen.install --yes; + choco install visualstudio2017buildtools --yes; + choco install nsis --yes; +fi +if [[ $TRAVIS_OS_NAME == "osx" ]]; then + bew update; + brew install make; + brew install doxygen; +fi + +exit 0; From 4f49c64125a639266bd7ccb7bfce286455abb966 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 11:41:27 -0400 Subject: [PATCH 149/217] Update .travis.yml --- .travis.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index c62b0461..e64f00f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,31 +17,19 @@ matrix: os: windows before_install: +- chmod 777 travis_scripts/* - export PRODUCTION="issue-480" -- if [[ $TRAVIS_OS_NAME == "linux" ]]; then - sudo apt-get update; - sudo apt-get install -y make; - sudo apt-get install -y doxygen; - fi -- if [[ $TRAVIS_OS_NAME == "windows" ]]; then - choco install make --yes; - choco install doxygen.install --yes; - choco install visualstudio2017buildtools --yes; - choco install nsis --yes; - fi -- if [[ $TRAVIS_OS_NAME == "osx" ]]; then - bew update; - brew install make; - brew install doxygen; - fi +- travis_retry ./travis_scripts/before_install.sh - node --version install: - travis_retry npm install script: - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then export PACKAGE="ON"; + export TESTING="OFF"; else export PACKAGE="OFF"; + export TESTING="ON"; fi #- ls -a - cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ From 073363006860549b764b0f2d662c9568c6d0a9aa Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 9 Mar 2020 12:04:20 -0400 Subject: [PATCH 150/217] Converted Travis scripts from DOS to UNIX --- travis_scripts/before_install.sh | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/travis_scripts/before_install.sh b/travis_scripts/before_install.sh index db43dc03..cdabfac1 100644 --- a/travis_scripts/before_install.sh +++ b/travis_scripts/before_install.sh @@ -1,22 +1,22 @@ -#!/bin/bash - -set -ev - -if [[ $TRAVIS_OS_NAME == "linux" ]]; then - sudo apt-get update; - sudo apt-get install -y make; - sudo apt-get install -y doxygen; -fi -if [[ $TRAVIS_OS_NAME == "windows" ]]; then - choco install make --yes; - choco install doxygen.install --yes; - choco install visualstudio2017buildtools --yes; - choco install nsis --yes; -fi -if [[ $TRAVIS_OS_NAME == "osx" ]]; then - bew update; - brew install make; - brew install doxygen; -fi - -exit 0; +#!/bin/bash + +set -ev + +if [[ $TRAVIS_OS_NAME == "linux" ]]; then + sudo apt-get update; + sudo apt-get install -y make; + sudo apt-get install -y doxygen; +fi +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + choco install make --yes; + choco install doxygen.install --yes; + choco install visualstudio2017buildtools --yes; + choco install nsis --yes; +fi +if [[ $TRAVIS_OS_NAME == "osx" ]]; then + bew update; + brew install make; + brew install doxygen; +fi + +exit 0; From 122648fc4a7b0336a4b0ce9e93bba2e8e649d66c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 12:36:08 -0400 Subject: [PATCH 151/217] Update before_install.sh --- travis_scripts/before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis_scripts/before_install.sh b/travis_scripts/before_install.sh index cdabfac1..44f569b5 100644 --- a/travis_scripts/before_install.sh +++ b/travis_scripts/before_install.sh @@ -14,7 +14,7 @@ if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install nsis --yes; fi if [[ $TRAVIS_OS_NAME == "osx" ]]; then - bew update; + brew update; brew install make; brew install doxygen; fi From 37b49b3b549fda80bfc07485a2c782ebdb557f5d Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 12:49:51 -0400 Subject: [PATCH 152/217] Update build.sh --- travis_scripts/build.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/travis_scripts/build.sh b/travis_scripts/build.sh index e69de29b..a3e8c0f4 100644 --- a/travis_scripts/build.sh +++ b/travis_scripts/build.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -ev + +cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ +cmake --build . --config Release + +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ./Release/amo_tools_suite_tests; +else + ./bin/amo_tools_suite_tests; +fi + +npm run test +npm run at + + +if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + if [[ $TRAVIS_OS_NAME == 'windows' ]]; then + travis_retry cmake --build . --config Release --target PACKAGE; + else + make package; + fi +else + echo "." +fi + + +exit 0; From 7d5e9fb71b1ccd59b879e00ff0cfad1470467026 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 12:52:18 -0400 Subject: [PATCH 153/217] Update build.sh --- travis_scripts/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/travis_scripts/build.sh b/travis_scripts/build.sh index a3e8c0f4..3d61785a 100644 --- a/travis_scripts/build.sh +++ b/travis_scripts/build.sh @@ -14,6 +14,11 @@ fi npm run test npm run at +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + echo "Skipping Doxygen"; +else + doxygen Doxyfile.in; +fi if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then if [[ $TRAVIS_OS_NAME == 'windows' ]]; then From 9c095a7fbad2f0f2bc2d20ff10ebd6d43e570e6f Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 9 Mar 2020 12:56:17 -0400 Subject: [PATCH 154/217] Renamed build.sh to build_test.sh --- travis_scripts/{build.sh => build_test.sh} | 68 +++++++++++----------- 1 file changed, 34 insertions(+), 34 deletions(-) rename travis_scripts/{build.sh => build_test.sh} (94%) diff --git a/travis_scripts/build.sh b/travis_scripts/build_test.sh similarity index 94% rename from travis_scripts/build.sh rename to travis_scripts/build_test.sh index 3d61785a..047fc064 100644 --- a/travis_scripts/build.sh +++ b/travis_scripts/build_test.sh @@ -1,34 +1,34 @@ -#!/bin/bash - -set -ev - -cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ -cmake --build . --config Release - -if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ./Release/amo_tools_suite_tests; -else - ./bin/amo_tools_suite_tests; -fi - -npm run test -npm run at - -if [[ $TRAVIS_OS_NAME == "windows" ]]; then - echo "Skipping Doxygen"; -else - doxygen Doxyfile.in; -fi - -if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - if [[ $TRAVIS_OS_NAME == 'windows' ]]; then - travis_retry cmake --build . --config Release --target PACKAGE; - else - make package; - fi -else - echo "." -fi - - -exit 0; +#!/bin/bash + +set -ev + +cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ +cmake --build . --config Release + +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + ./Release/amo_tools_suite_tests; +else + ./bin/amo_tools_suite_tests; +fi + +npm run test +npm run at + +if [[ $TRAVIS_OS_NAME == "windows" ]]; then + echo "Skipping Doxygen"; +else + doxygen Doxyfile.in; +fi + +if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + if [[ $TRAVIS_OS_NAME == 'windows' ]]; then + travis_retry cmake --build . --config Release --target PACKAGE; + else + make package; + fi +else + echo "." +fi + + +exit 0; From 9e1e07783f2f72d2017dfa504b17536ef79830af Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 12:58:27 -0400 Subject: [PATCH 155/217] Update .travis.yml --- .travis.yml | 49 +++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index e64f00f6..429a4b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,10 @@ if: tag IS blank language: node_js node_js: -- 12.8.0 + - 12.8.0 compiler: -- gcc + - gcc matrix: include: @@ -17,44 +17,17 @@ matrix: os: windows before_install: -- chmod 777 travis_scripts/* -- export PRODUCTION="issue-480" -- travis_retry ./travis_scripts/before_install.sh -- node --version + - chmod 777 travis_scripts/* + - export PRODUCTION="issue-480" + - travis_retry ./travis_scripts/before_install.sh + - node --version install: -- travis_retry npm install + - travis_retry npm install script: -- if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - export PACKAGE="ON"; - export TESTING="OFF"; - else - export PACKAGE="OFF"; - export TESTING="ON"; - fi -#- ls -a -- cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ -- cmake --build . --config Release -#- ls -a -- if [[ $TRAVIS_OS_NAME == "windows" ]]; then - ./Release/amo_tools_suite_tests; - else - ./bin/amo_tools_suite_tests; - fi -- npm run test -- npm run at -- if [[ $TRAVIS_OS_NAME == "windows" ]]; then - echo "Skipping Doxygen"; - else - doxygen Doxyfile.in; - fi -#- echo "$TRAVIS_OS_NAME" -#- bash travis_scripts/package_release.sh -- if [ [$TRAVIS_OS_NAME == 'windows'] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry cmake --build . --config Release --target PACKAGE; fi - -- if [ [$TRAVIS_OS_NAME != 'windows'] AND [$TRAVIS_BRANCH == $PRODUCTION] ]; then travis_retry make package; fi - -- ls -a -#- ls -a Release/ + - travis_retry ./travis_scripts/build_test.sh + - ls -a + - echo "Building and testing complete" + #- ls -a Release/ before_deploy: #function keep_alive() { # while true; do From 32884fd9fb93a404046c16a033924bf1cda83200 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:01:57 -0400 Subject: [PATCH 156/217] Update .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 429a4b8d..91580128 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,11 @@ before_install: install: - travis_retry npm install script: + - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + export PACKAGE="ON"; + else + export PACKAGE="OFF"; + fi - travis_retry ./travis_scripts/build_test.sh - ls -a - echo "Building and testing complete" From c3cd5c4e7e8b31931ade737a596294c9996e591e Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:03:26 -0400 Subject: [PATCH 157/217] Update build_test.sh --- travis_scripts/build_test.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/travis_scripts/build_test.sh b/travis_scripts/build_test.sh index 047fc064..47b5e1d8 100644 --- a/travis_scripts/build_test.sh +++ b/travis_scripts/build_test.sh @@ -2,6 +2,12 @@ set -ev +if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then + export PACKAGE="ON"; +else + export PACKAGE="OFF"; +fi + cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=$PACKAGE ./ cmake --build . --config Release From 88f2175ac7585e056796a1829c562ec432f712db Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:03:38 -0400 Subject: [PATCH 158/217] Update .travis.yml --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91580128..429a4b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,11 +24,6 @@ before_install: install: - travis_retry npm install script: - - if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then - export PACKAGE="ON"; - else - export PACKAGE="OFF"; - fi - travis_retry ./travis_scripts/build_test.sh - ls -a - echo "Building and testing complete" From eeac762ea451ebbc575c38524b780cb9e29add06 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:15:41 -0400 Subject: [PATCH 159/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 429a4b8d..9b41e9ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: install: - travis_retry npm install script: - - travis_retry ./travis_scripts/build_test.sh + - ./travis_scripts/build_test.sh - ls -a - echo "Building and testing complete" #- ls -a Release/ From 6fe8ae854a792e19f79e26128abf64250eb34b0c Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:25:02 -0400 Subject: [PATCH 160/217] Update build_test.sh --- travis_scripts/build_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis_scripts/build_test.sh b/travis_scripts/build_test.sh index 47b5e1d8..1234dbe7 100644 --- a/travis_scripts/build_test.sh +++ b/travis_scripts/build_test.sh @@ -28,7 +28,7 @@ fi if [[ $TRAVIS_BRANCH == $PRODUCTION ]]; then if [[ $TRAVIS_OS_NAME == 'windows' ]]; then - travis_retry cmake --build . --config Release --target PACKAGE; + cmake --build . --config Release --target PACKAGE; else make package; fi From a7f5d40a806551b19d84c35ea4277e30720da212 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:25:27 -0400 Subject: [PATCH 161/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9b41e9ab..429a4b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: install: - travis_retry npm install script: - - ./travis_scripts/build_test.sh + - travis_retry ./travis_scripts/build_test.sh - ls -a - echo "Building and testing complete" #- ls -a Release/ From fea5dbbbe52a2320e05ab74c54bc87e4dac92b03 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:35:48 -0400 Subject: [PATCH 162/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 429a4b8d..a1581996 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,6 +54,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: master + branch: issue-480 #condition: type = push AND branch = master #tags: false From e627dc0ea8febb993cb3464a974656fa1c6414f1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:59:16 -0400 Subject: [PATCH 163/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a1581996..429a4b8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,6 +54,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: issue-480 + branch: master #condition: type = push AND branch = master #tags: false From a31f173a0f26601305a17832ba9050e83622e2db Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 13:59:41 -0400 Subject: [PATCH 164/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 429a4b8d..064f7a0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: before_install: - chmod 777 travis_scripts/* - - export PRODUCTION="issue-480" + - export PRODUCTION="master" - travis_retry ./travis_scripts/before_install.sh - node --version install: From 893eb3d1780a3fb6e9d316c608ef7bc22c8bbd42 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 14:17:03 -0400 Subject: [PATCH 165/217] Update build_test.sh --- travis_scripts/build_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/travis_scripts/build_test.sh b/travis_scripts/build_test.sh index 1234dbe7..790dfb0f 100644 --- a/travis_scripts/build_test.sh +++ b/travis_scripts/build_test.sh @@ -21,7 +21,8 @@ npm run test npm run at if [[ $TRAVIS_OS_NAME == "windows" ]]; then - echo "Skipping Doxygen"; + #echo "Skipping Doxygen"; + doxygen Doxyfile.in; else doxygen Doxyfile.in; fi From b65b9690736fea1def9f0173a5c9a5f9838b6ac1 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 14:27:16 -0400 Subject: [PATCH 166/217] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 064f7a0b..c808054f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_install: install: - travis_retry npm install script: - - travis_retry ./travis_scripts/build_test.sh + - ./travis_scripts/build_test.sh - ls -a - echo "Building and testing complete" #- ls -a Release/ From 531b3bd26d3b56a79a4f8fe16893911512c577b8 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 14:27:34 -0400 Subject: [PATCH 167/217] Update build_test.sh --- travis_scripts/build_test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/travis_scripts/build_test.sh b/travis_scripts/build_test.sh index 790dfb0f..1234dbe7 100644 --- a/travis_scripts/build_test.sh +++ b/travis_scripts/build_test.sh @@ -21,8 +21,7 @@ npm run test npm run at if [[ $TRAVIS_OS_NAME == "windows" ]]; then - #echo "Skipping Doxygen"; - doxygen Doxyfile.in; + echo "Skipping Doxygen"; else doxygen Doxyfile.in; fi From 473b4295c653ed9222a6a256a1efbe9a35fcfb02 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 14:44:49 -0400 Subject: [PATCH 168/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c808054f..7369a5d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: before_install: - chmod 777 travis_scripts/* - - export PRODUCTION="master" + - export PRODUCTION="issue-480" - travis_retry ./travis_scripts/before_install.sh - node --version install: @@ -54,6 +54,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: master + branch: issue-480 #condition: type = push AND branch = master #tags: false From 0d1433b076d3d645f7a10828b3e15f3e5e9f54a7 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Mon, 9 Mar 2020 15:04:15 -0400 Subject: [PATCH 169/217] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7369a5d8..c808054f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ matrix: before_install: - chmod 777 travis_scripts/* - - export PRODUCTION="issue-480" + - export PRODUCTION="master" - travis_retry ./travis_scripts/before_install.sh - node --version install: @@ -54,6 +54,6 @@ deploy: #tag_name: "release_draft" on: repo: ORNL-AMO/AMO-Tools-Suite - branch: issue-480 + branch: master #condition: type = push AND branch = master #tags: false From cda2f9f22ae346f5d4d5dca75c4fdf35461e5844 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 10 Mar 2020 09:00:41 -0400 Subject: [PATCH 170/217] Updated Fan203.h with correct constants --- Docker/docker_commands.txt | 6 +++--- include/fans/Fan203.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt index 536d3998..55684b2f 100644 --- a/Docker/docker_commands.txt +++ b/Docker/docker_commands.txt @@ -1,10 +1,10 @@ -docker image build -f Docker/Dockerfile -t comma64/ornl:issue-258 . -docker run -t -d --name amo-suite comma64/ornl:issue-258 +docker image build -f Docker/Dockerfile -t comma64/ornl:amo-tools-suite . +docker run -t -d --name amo-suite comma64/ornl:amo-tools-suite docker exec -it amo-suite /bin/bash docker container rm --force amo-suite docker login -docker push comma64/ornl:issue-258 +docker push comma64/ornl:amo-tools-suite diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 002cbbb3..dbfe0d27 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -126,9 +126,9 @@ class BaseGasDensity */ double calculateSaturationPressure(double dryBulbTemp) const { - double const C1 = -5674.5359, C2 = -0.51523058, C3 = -0.009677843, C4 = 0.00000062215701; - double const C5 = 2.0747825 * std::pow(10, -9), C6 = -9.0484024 * std::pow(10, -13), C7 = 4.1635019, C8 = -5800.2206; - double const C9 = -5.516256, C10 = -0.048640239, C11 = 0.000041764768, C12 = -0.000000014452093, C13 = 6.5459673; + double const C1 = -5674.5359, C2 = 6.3925247, C3 = -0.009677843, C4 = 0.00000062215701; + double const C5 = 2.0747825 * std::pow(10, -9), C6 = -9.484024 * std::pow(10, -13), C7 = 4.1635019; + double const C8 = -5800.2206, C9 = 1.3914093, C10 = -0.048640239, C11 = 0.000041764768, C12 = -0.000000014452093, C13 = 6.5459673; double const tKelvin = (dryBulbTemp + 459.67) * 0.555556; From fdc5c15baf7fe7bceff137b7d9c3fda910c639e9 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 10 Mar 2020 15:23:10 -0400 Subject: [PATCH 171/217] Updated Fan203 constants and corresponding C++ unit test --- include/fans/Fan203.h | 7 +++++-- tests/Fan.unit.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index dbfe0d27..af15b8cb 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -19,6 +19,9 @@ #include "Planar.h" #include "FanShaftPower.h" +#include +#include + class FanRatedInfo; class Planar; class FlangePlane; @@ -135,11 +138,11 @@ class BaseGasDensity if (tKelvin < 273.15) { double const p = std::exp(C1 / tKelvin + C2 + tKelvin * C3 + tKelvin * tKelvin * (C4 + tKelvin * (C5 + C6 * tKelvin)) + C7 * std::log(tKelvin)); - return p * (29.9216 / 101.325); + return p * (29.9216 / 101325); } double const p = std::exp(C8 / tKelvin + C9 + tKelvin * (C10 + tKelvin * (C11 + tKelvin * C12)) + C13 * std::log(tKelvin)); - return p * (29.9216 / 101.325); + return p * (29.9216 / 101325); } /** * @brief Calculates Relative Humidity Ratio diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 4111bdf5..bd33e117 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -167,5 +167,5 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { auto const bdg = BaseGasDensity( 70, 26.62, 29.92, 60, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); - CHECK(bdg.getGasDensity() == Approx(0.08143)); + CHECK(bdg.getGasDensity() == Approx(0.08143315)); } From 59a920d87a9af4d1aa26056bf8596865bebd54eb Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 13 Mar 2020 12:12:02 -0400 Subject: [PATCH 172/217] Updated documentation in Fan203.h --- Docker/Dockerfile | 2 ++ Docker/docker_commands.txt | 7 +++++++ include/fans/Fan203.h | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index ae3d5b6a..27421132 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -140,6 +140,8 @@ RUN node-gyp rebuild RUN npm run test RUN npm run at + +RUN doxygen Doxyfile.in #-------------------------------------------------------------- #WORKDIR /home/ diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt index 55684b2f..95b12d54 100644 --- a/Docker/docker_commands.txt +++ b/Docker/docker_commands.txt @@ -1,7 +1,14 @@ docker image build -f Docker/Dockerfile -t comma64/ornl:amo-tools-suite . docker run -t -d --name amo-suite comma64/ornl:amo-tools-suite + +# Mount a host directory to persist source code and builds +docker run -t -d -v "/home/81c/AMO/src:/home/AMO/src/" --name amo-suite comma64/ornl:amo-tools-suite + + docker exec -it amo-suite /bin/bash + docker container rm --force amo-suite +docker rmi comma64/ornl:amo-tools-suite docker login docker push comma64/ornl:amo-tools-suite diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index af15b8cb..b731ed1f 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -76,7 +76,13 @@ class BaseGasDensity * @param gasType, double, gas, type of gas, unitless * @param inputType const, type of input, unitless * @param specificGravity, double, const, specific gravity, unitless - * @return BaseGasDensity double, density of the gas in pounds per sqft, lb/scf + * @param pIn double, Absolute Pressure In in in Hg + * @param satW double, Saturated Humidity Ratio, unitless + * @param satDeg double, Degree of Saturation, unitless + * @param humW double, Humidity Ratio, unitless + * @param specVol double, Specific Volume, ft^3/lb + * @param satPress double, Saturation Pressure, in Hg + * @return density double, density of the gas in pounds per sqft, lb/scf */ // TODO ensure correctness BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, @@ -126,6 +132,7 @@ class BaseGasDensity * @brief Calculates Saturation Pressure * * @param dryBulbTemp double, temperature of inputted air in °F + * @return satPress double, Saturation Pressure, in Hg */ double calculateSaturationPressure(double dryBulbTemp) const { @@ -151,6 +158,7 @@ class BaseGasDensity * @param relativeHumidity double, relative humidity as % * @param barometricPressure double, pressure in Hg * @param specificGravity double, specific gravity, unitless + * @return humW double, Humidity Ratio, unitless */ double calculateRatioRH(const double dryBulbTemp, const double relativeHumidity, const double barometricPressure, const double specificGravity) const From 358d8831fade59f126ced0ccd1ccb1b5579bde7b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 13 Mar 2020 15:20:15 -0400 Subject: [PATCH 173/217] Reworking BaseGasDensity in Fan203.h --- include/fans/Fan203.h | 56 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index b731ed1f..23005896 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -76,12 +76,12 @@ class BaseGasDensity * @param gasType, double, gas, type of gas, unitless * @param inputType const, type of input, unitless * @param specificGravity, double, const, specific gravity, unitless - * @param pIn double, Absolute Pressure In in in Hg - * @param satW double, Saturated Humidity Ratio, unitless - * @param satDeg double, Degree of Saturation, unitless - * @param humW double, Humidity Ratio, unitless - * @param specVol double, Specific Volume, ft^3/lb - * @param satPress double, Saturation Pressure, in Hg + * @return pIn double, Absolute Pressure In in in Hg + * @return satW double, Saturated Humidity Ratio, unitless + * @return satDeg double, Degree of Saturation, unitless + * @return humW double, Humidity Ratio, unitless + * @return specVol double, Specific Volume, ft^3/lb + * @return satPress double, Saturation Pressure, in Hg * @return density double, density of the gas in pounds per sqft, lb/scf */ // TODO ensure correctness @@ -105,8 +105,40 @@ class BaseGasDensity throw std::runtime_error("The wrong constructor for BaseGasDensity was called here - check inputType field"); } + /* double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh * rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); + */ + + pIn = pbo + (pso/13.3); + satW = 0.62198 * satPress/(pIn – satPress); + satDeg = rh / ( 1 + ( 1 – rh) * satW/0.62198); + humW = satDeg * satW; + specVol = (10.731557* (tdo + 459.67) * (1 + 1.6078 * humW))/(28.9645 * pIn * 0.491541); + po = (1 / specVol) * (1 + humW); + double const enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); + + if(inputType != inputType::DewPoint) + { + double const alpha = std::log(pIn*0.4911541*humW / (0.62196 + humW)); + + if(tdo < 32) + { + double const dewPoint = 90.12+26.412* alpha +0.8927* alpha * alpha; + } + else + { + // Fix this. Needs different exponent function + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * ((std::exp (alpha)) ^ 0.1984)); + } + + } + else // ? + { + relativeHumidityOrDewPoint; + } + + } BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, @@ -118,8 +150,10 @@ class BaseGasDensity throw std::runtime_error("The wrong constructor for BaseGasDensity was called - check inputType field"); double const satPress = calculateSaturationPressure(tdo); double const rh = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); + /* double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh + rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); + */ } double getGasDensity() const @@ -198,6 +232,16 @@ class BaseGasDensity double po, g; const GasType gasType; + /** + * @param pIn double, Absolute Pressure In in in Hg XXX + * @param satW double, Saturated Humidity Ratio, unitless + * @param satDeg double, Degree of Saturation, unitless + * @param humW double, Humidity Ratio, unitless + * @param specVol double, Specific Volume, ft^3/lb + * @param satPress double, Saturation Pressure, in Hg + */ + double pIn, satW, satDeg, humW, specVol, satPress; + friend class PlaneData; friend class Fan203; }; From e29acfc3c28018aa3c1a6b0aa72702add2494abe Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 16 Mar 2020 15:47:39 -0400 Subject: [PATCH 174/217] Reworked calculations in Fan203.h and added more tests to unit test --- include/fans/Fan203.h | 100 ++++++++++++++++++++++++++++++++++-------- tests/Fan.unit.cpp | 43 +++++++++++++++++- 2 files changed, 123 insertions(+), 20 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 23005896..9cf4c542 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -3,6 +3,7 @@ * * @author Preston Shires (pshires) * @author Allie Ledbetter (Aeledbetter) + * @author Colin Causey (causeyc) * @bug No known bugs. * */ @@ -90,8 +91,8 @@ class BaseGasDensity InputType const inputType, double const specificGravity) : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), g(specificGravity), gasType(gasType) { - double const satPress = calculateSaturationPressure(tdo); - double rh = 0; + satPress = calculateSaturationPressure(tdo); + rh = 0; if (inputType == InputType::RelativeHumidity) { rh = relativeHumidityOrDewPoint / 100; @@ -110,34 +111,35 @@ class BaseGasDensity po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh * rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); */ - pIn = pbo + (pso/13.3); - satW = 0.62198 * satPress/(pIn – satPress); - satDeg = rh / ( 1 + ( 1 – rh) * satW/0.62198); + pIn = pbo + (pso / 13.608703); + satW = 0.62198 * satPress / (pIn - satPress); + satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); humW = satDeg * satW; - specVol = (10.731557* (tdo + 459.67) * (1 + 1.6078 * humW))/(28.9645 * pIn * 0.491541); + specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); po = (1 / specVol) * (1 + humW); - double const enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); + enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); - if(inputType != inputType::DewPoint) + if(inputType != InputType::DewPoint) { - double const alpha = std::log(pIn*0.4911541*humW / (0.62196 + humW)); + double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); if(tdo < 32) { - double const dewPoint = 90.12+26.412* alpha +0.8927* alpha * alpha; + dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; + //dewPoint = 1; } else { - // Fix this. Needs different exponent function - dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * ((std::exp (alpha)) ^ 0.1984)); + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); + //dewPoint = 2; } } - else // ? + else { - relativeHumidityOrDewPoint; + dewPoint = relativeHumidityOrDewPoint; + //dewPoint = 3; } - } @@ -148,18 +150,74 @@ class BaseGasDensity { if (inputType != InputType::WetBulbTemp) throw std::runtime_error("The wrong constructor for BaseGasDensity was called - check inputType field"); - double const satPress = calculateSaturationPressure(tdo); - double const rh = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); + satPress = calculateSaturationPressure(tdo); + rh = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); /* double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh + rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); */ + pIn = pbo + (pso / 13.608703); + satW = 0.62198 * satPress / (pIn - satPress); + satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); + humW = satDeg * satW; + specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); + po = (1 / specVol) * (1 + humW); + enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); + + double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); + + if(tdo < 32) + { + dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; + //dewPoint = 1; + } + else + { + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); + //dewPoint = 2; + } } double getGasDensity() const { return po; } + double getAbsolutePressureIn() const + { + return pIn; + } + double getSaturatedHumidityRatio() const + { + return satW; + } + double getDegreeOfSaturation() const + { + return satDeg; + } + double getHumidityRatio() const + { + return humW; + } + double getSpecificVolume() const + { + return specVol; + } + double getEnthalpy() const + { + return enthalpy; + } + double getDewPoint() const + { + return dewPoint; + } + double getRelativeHumidity() const + { + return rh; + } + double getSaturationPressure() const + { + return satPress; + } private: /** @@ -215,7 +273,8 @@ class BaseGasDensity // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); double const wStar = nMol * psatWb / (pAtm - psatWb); - double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); + //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); + double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); double const pV = pAtm * w / (nMol + w); return pV / psatDb; @@ -238,9 +297,12 @@ class BaseGasDensity * @param satDeg double, Degree of Saturation, unitless * @param humW double, Humidity Ratio, unitless * @param specVol double, Specific Volume, ft^3/lb + * @param entropy double, Entropy, B/lb + * @param dewPoint double, Dewpoint, deg F + * @param rh double, Relative Humidity, % * @param satPress double, Saturation Pressure, in Hg */ - double pIn, satW, satDeg, humW, specVol, satPress; + double pIn, satW, satDeg, humW, specVol, enthalpy, dewPoint, rh, satPress; friend class PlaneData; friend class Fan203; diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index bd33e117..48a0c000 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -167,5 +167,46 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { auto const bdg = BaseGasDensity( 70, 26.62, 29.92, 60, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); - CHECK(bdg.getGasDensity() == Approx(0.08143315)); + //CHECK(bdg.getGasDensity() == Approx(0.08143315)); + + CHECK(bdg.getGasDensity() == Approx(0.0794202473)); + CHECK(bdg.getAbsolutePressureIn() == Approx(31.8761011803)); + CHECK(bdg.getSaturatedHumidityRatio() == Approx(0.014773)); + CHECK(bdg.getDegreeOfSaturation() == Approx(0.5943528804)); + CHECK(bdg.getHumidityRatio() == Approx(0.0087806)); + CHECK(bdg.getSpecificVolume() == Approx(12.7018112191)); + CHECK(bdg.getEnthalpy() == Approx(26.87954206)); + CHECK(bdg.getDewPoint() == Approx(55.5523108718)); + CHECK(bdg.getRelativeHumidity() == Approx(0.60)); + CHECK(bdg.getSaturationPressure() == Approx(0.7395925636)); + + auto const bdg2 = BaseGasDensity( + 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 + ); + + CHECK(bdg2.getGasDensity() == Approx(0.0794202473)); + CHECK(bdg2.getAbsolutePressureIn() == Approx(31.8761011803)); + CHECK(bdg2.getSaturatedHumidityRatio() == Approx(0.014773)); + CHECK(bdg2.getDegreeOfSaturation() == Approx(0.5945291299)); + CHECK(bdg2.getHumidityRatio() == Approx(0.0087806)); + CHECK(bdg2.getSpecificVolume() == Approx(12.7018112191)); + CHECK(bdg2.getEnthalpy() == Approx(26.882385744)); + CHECK(bdg2.getDewPoint() == Approx(55.5)); + CHECK(bdg2.getRelativeHumidity() == Approx(0.6001754464)); + CHECK(bdg2.getSaturationPressure() == Approx(0.7395925636)); + + auto const bdg3 = BaseGasDensity( + 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 + ); + + CHECK(bdg3.getGasDensity() == Approx(0.079326234)); + CHECK(bdg3.getAbsolutePressureIn() == Approx(31.8761011803)); + CHECK(bdg3.getSaturatedHumidityRatio() == Approx(0.014773)); + CHECK(bdg3.getDegreeOfSaturation() == Approx(0.595)); + CHECK(bdg3.getHumidityRatio() == Approx(0.0087834)); + CHECK(bdg3.getSpecificVolume() == Approx(12.71)); + CHECK(bdg3.getEnthalpy() == Approx(26.39)); + CHECK(bdg3.getDewPoint() == Approx(55.51)); + CHECK(bdg3.getRelativeHumidity() == Approx(0.6002)); + CHECK(bdg3.getSaturationPressure() == Approx(0.07867490)); } From cf78fd0a35915c62f008470b54279a209bd6d0b4 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 17 Mar 2020 11:22:25 -0400 Subject: [PATCH 175/217] Updated functions in Fan203.h --- include/fans/Fan203.h | 53 ++++++++++++++++++++++++++++++++++++++++--- tests/Fan.unit.cpp | 2 +- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 9cf4c542..d11c5dc9 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -111,6 +111,8 @@ class BaseGasDensity po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh * rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); */ + calculateFanAttributes(inputType, relativeHumidityOrDewPoint); + /* pIn = pbo + (pso / 13.608703); satW = 0.62198 * satPress / (pIn - satPress); satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); @@ -140,6 +142,7 @@ class BaseGasDensity dewPoint = relativeHumidityOrDewPoint; //dewPoint = 3; } + */ } @@ -156,6 +159,9 @@ class BaseGasDensity double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh + rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); */ + + calculateFanAttributes(inputType); + /* pIn = pbo + (pso / 13.608703); satW = 0.62198 * satPress / (pIn - satPress); satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); @@ -176,6 +182,7 @@ class BaseGasDensity dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); //dewPoint = 2; } + */ } double getGasDensity() const @@ -268,17 +275,57 @@ class BaseGasDensity double calculateRelativeHumidityFromWetBulb(const double dryBulbTemp, const double wetBulbTemp, const double cpGas) const { - double const pAtm = 29.9213 / pbo, nMol = 18.02 / (g * 28.98); + double const nMol = 0.62198; + //double const pAtm = 29.9213 / pbo, nMol = 18.02 / (g * 28.98); double const psatDb = calculateSaturationPressure(dryBulbTemp); // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); - double const wStar = nMol * psatWb / (pAtm - psatWb); + double const wStar = nMol * psatWb / (pbo - psatWb); //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); - double const pV = pAtm * w / (nMol + w); + double const pV = pbo * w / (nMol + w); return pV / psatDb; } + /** + * @brief Calculates numerous fan attributes. Note: This function assumes that the member variables pbo, pso, satPress, and rh already + have valid values. + * + * @param inputType const, type of input, unitless + * @param relativeHumidityOrDewPoint double, const, relative humidity in % or Dewpoint in °F + */ + void calculateFanAttributes(InputType const inputType, double const relativeHumidityOrDewPoint = -1) + { + pIn = pbo + (pso / 13.608703); + satW = 0.62198 * satPress / (pIn - satPress); + satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); + humW = satDeg * satW; + specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); + po = (1 / specVol) * (1 + humW); + enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); + + if(inputType != InputType::DewPoint) + { + double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); + + if(tdo < 32) + { + dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; + //dewPoint = 1; + } + else + { + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); + //dewPoint = 2; + } + + } + else + { + dewPoint = relativeHumidityOrDewPoint; + //dewPoint = 3; + } + } // dry bulb temp, reference static pressure, reference barometric pressure, gas density respectively const double tdo, pso, pbo; diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 48a0c000..dbf23912 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -198,7 +198,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 ); - + CHECK(bdg3.getGasDensity() == Approx(0.079326234)); CHECK(bdg3.getAbsolutePressureIn() == Approx(31.8761011803)); CHECK(bdg3.getSaturatedHumidityRatio() == Approx(0.014773)); From 4715ca2dfb62dd3a25220081a363bf9252dc51cd Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 17 Mar 2020 16:12:51 -0400 Subject: [PATCH 176/217] Updated JS fan tests --- include/fans/Fan203.h | 12 ++++++++++++ tests/Fan.unit.cpp | 3 ++- tests/js/fanTest.js | 9 ++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index d11c5dc9..34f1e380 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -112,6 +112,12 @@ class BaseGasDensity */ calculateFanAttributes(inputType, relativeHumidityOrDewPoint); + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "Answer: " << po << std::endl; + fout << "------------------------------" << std::endl << std::endl; + fout.close(); + /* pIn = pbo + (pso / 13.608703); satW = 0.62198 * satPress / (pIn - satPress); @@ -161,6 +167,12 @@ class BaseGasDensity */ calculateFanAttributes(inputType); + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "Answer: " << po << std::endl; + fout << "------------------------------" << std::endl << std::endl; + fout.close(); + /* pIn = pbo + (pso / 13.608703); satW = 0.62198 * satPress / (pIn - satPress); diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index dbf23912..28e78b23 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -198,7 +198,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 ); - + /* CHECK(bdg3.getGasDensity() == Approx(0.079326234)); CHECK(bdg3.getAbsolutePressureIn() == Approx(31.8761011803)); CHECK(bdg3.getSaturatedHumidityRatio() == Approx(0.014773)); @@ -209,4 +209,5 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg3.getDewPoint() == Approx(55.51)); CHECK(bdg3.getRelativeHumidity() == Approx(0.6002)); CHECK(bdg3.getSaturationPressure() == Approx(0.07867490)); + */ } diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index da49f29f..0962d6d1 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -181,7 +181,8 @@ test('getBaseGasDensity', function (t) { }; var res = bindings.getBaseGasDensityRelativeHumidity(inp); - t.equal(rnd(res), rnd(0.06231117736966)); + //t.equal(rnd(res), rnd(0.06231117736966)); + t.equal(rnd(res), rnd(0.0564228)); inp = { dryBulbTemp: 123, @@ -195,7 +196,8 @@ test('getBaseGasDensity', function (t) { }; res = bindings.getBaseGasDensityDewPoint(inp); - t.equal(rnd(res), rnd(0.06551801779516826)); + //t.equal(rnd(res), rnd(0.06551801779516826)); + t.equal(rnd(res), rnd(0.057519)); inp = { dryBulbTemp: 123, @@ -210,7 +212,8 @@ test('getBaseGasDensity', function (t) { }; res = bindings.getBaseGasDensityWetBulb(inp); - t.equal(rnd(res), rnd(0.065456)); + //t.equal(rnd(res), rnd(0.065456)); + t.equal(rnd(res), rnd(0.0557205)); }); test('getVelocityPressureData', function (t) { From 514484480230050b46befe08096fc48a9b1699db Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 18 Mar 2020 16:26:46 -0400 Subject: [PATCH 177/217] Added BaseGasDensity object function to bindings and updated bindings tests --- Docker/Dockerfile | 10 +++---- bindings/fan.cpp | 3 +++ bindings/fan.h | 61 +++++++++++++++++++++++++++++++++++++++++++ include/fans/Fan203.h | 34 +++++++++++++++++++++--- tests/Fan.unit.cpp | 2 +- tests/js/fanTest.js | 25 +++++++++++++++++- 6 files changed, 125 insertions(+), 10 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 27421132..ad951e95 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -133,15 +133,15 @@ RUN cmake --build . RUN ./bin/amo_tools_suite_tests -RUN npm install +#RUN npm install -RUN node-gyp rebuild +#RUN node-gyp rebuild -RUN npm run test +#RUN npm run test -RUN npm run at +#RUN npm run at -RUN doxygen Doxyfile.in +#RUN doxygen Doxyfile.in #-------------------------------------------------------------- #WORKDIR /home/ diff --git a/bindings/fan.cpp b/bindings/fan.cpp index bf546a23..3d00ae9e 100644 --- a/bindings/fan.cpp +++ b/bindings/fan.cpp @@ -15,6 +15,9 @@ NAN_MODULE_INIT(InitFans) { Nan::Set(target, New("fan203").ToLocalChecked(), GetFunction(New(fan203)).ToLocalChecked()); + Nan::Set(target, New("getBaseGasDensityObj").ToLocalChecked(), + GetFunction(New(getBaseGasDensityObj)).ToLocalChecked()); + Nan::Set(target, New("getBaseGasDensityRelativeHumidity").ToLocalChecked(), GetFunction(New(getBaseGasDensityRelativeHumidity)).ToLocalChecked()); diff --git a/bindings/fan.h b/bindings/fan.h index 58e0cb23..23fd41a8 100644 --- a/bindings/fan.h +++ b/bindings/fan.h @@ -436,6 +436,67 @@ NAN_METHOD(fanResultsModified) // info.GetReturnValue().Set(r); // } +NAN_METHOD(getBaseGasDensityObj) +{ + // Local ??? + Local po = Nan::New("po").ToLocalChecked(); + Local pIn = Nan::New("pIn").ToLocalChecked(); + Local satW = Nan::New("satW").ToLocalChecked(); + Local satDeg = Nan::New("satDeg").ToLocalChecked(); + Local humW = Nan::New("humW").ToLocalChecked(); + Local specVol = Nan::New("specVol").ToLocalChecked(); + Local enthalpy = Nan::New("enthalpy").ToLocalChecked(); + Local dewPoint = Nan::New("dewPoint").ToLocalChecked(); + Local rh = Nan::New("rh").ToLocalChecked(); + Local satPress = Nan::New("satPress").ToLocalChecked(); + + Local obj = Nan::New(); + + inp = Nan::To(info[0]).ToLocalChecked(); + r = Nan::New(); + try + { + //NAN data init + const double dryBulbTemp = Get("dryBulbTemp", inp); + const double staticPressure = Get("staticPressure", inp); + const double barometricPressure = Get("barometricPressure", inp); + const double relativeHumidity = Get("relativeHumidity", inp); + BaseGasDensity::GasType gasType = getGasType(inp); + BaseGasDensity::InputType inputType = getInputType(inp); + const double specificGravity = Get("specificGravity", inp); + + //Calculation procedure + auto bgd = BaseGasDensity( + dryBulbTemp, + staticPressure, + barometricPressure, + relativeHumidity, + gasType, + inputType, + specificGravity); + + Nan::Set(obj, po, Nan::New(bgd.getGasDensity())); + Nan::Set(obj, pIn, Nan::New(bgd.getAbsolutePressureIn())); + Nan::Set(obj, satW, Nan::New(bgd.getSaturatedHumidityRatio())); + Nan::Set(obj, satDeg, Nan::New(bgd.getDegreeOfSaturation())); + Nan::Set(obj, humW, Nan::New(bgd.getHumidityRatio())); + Nan::Set(obj, specVol, Nan::New(bgd.getSpecificVolume())); + Nan::Set(obj, enthalpy, Nan::New(bgd.getEnthalpy())); + Nan::Set(obj, dewPoint, Nan::New(bgd.getDewPoint())); + Nan::Set(obj, rh, Nan::New(bgd.getRelativeHumidity())); + Nan::Set(obj, satPress, Nan::New(bgd.getSaturationPressure())); + + //NAN return object + info.GetReturnValue().Set(obj); + } + catch (std::runtime_error const &e) + { + info.GetReturnValue().Set(0); + std::string const what = e.what(); + ThrowError(std::string("std::runtime_error thrown in getBaseGasDensityRelativeHumidity - fan.h: " + what).c_str()); + } +} + NAN_METHOD(getBaseGasDensityRelativeHumidity) { inp = Nan::To(info[0]).ToLocalChecked(); diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 34f1e380..9fce1114 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -114,7 +114,16 @@ class BaseGasDensity calculateFanAttributes(inputType, relativeHumidityOrDewPoint); std::ofstream fout; fout.open("debug.txt", std::ios::app); - fout << "Answer: " << po << std::endl; + fout << "po: " << po << std::endl; + fout << "pIn: " << pIn << std::endl; + fout << "satW: " << satW << std::endl; + fout << "satDeg: " << satDeg << std::endl; + fout << "humW: " << humW << std::endl; + fout << "specVol: " << specVol << std::endl; + fout << "enthalpy: " << enthalpy << std::endl; + fout << "dewPoint: " << dewPoint << std::endl; + fout << "rh: " << rh << std::endl; + fout << "satPress: " << satPress << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); @@ -169,10 +178,20 @@ class BaseGasDensity calculateFanAttributes(inputType); std::ofstream fout; fout.open("debug.txt", std::ios::app); - fout << "Answer: " << po << std::endl; + fout << "Wet Bulb" << std::endl; + fout << "po: " << po << std::endl; + fout << "pIn: " << pIn << std::endl; + fout << "satW: " << satW << std::endl; + fout << "satDeg: " << satDeg << std::endl; + fout << "humW: " << humW << std::endl; + fout << "specVol: " << specVol << std::endl; + fout << "enthalpy: " << enthalpy << std::endl; + fout << "dewPoint: " << dewPoint << std::endl; + fout << "rh: " << rh << std::endl; + fout << "satPress: " << satPress << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); - + /* pIn = pbo + (pso / 13.608703); satW = 0.62198 * satPress / (pIn - satPress); @@ -297,6 +316,15 @@ class BaseGasDensity double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); double const pV = pbo * w / (nMol + w); + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "calculateRelativeHumidityFromWetBulb" << std::endl; + fout << "psatDb: " << psatDb << std::endl; + fout << "psatWb: " << psatWb << std::endl; + fout << "wStar: " << wStar << std::endl; + fout << "w: " << w << std::endl; + fout << "------------------------------" << std::endl << std::endl; + fout.close(); return pV / psatDb; } /** diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 28e78b23..78ebaaed 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -208,6 +208,6 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg3.getEnthalpy() == Approx(26.39)); CHECK(bdg3.getDewPoint() == Approx(55.51)); CHECK(bdg3.getRelativeHumidity() == Approx(0.6002)); - CHECK(bdg3.getSaturationPressure() == Approx(0.07867490)); + CHECK(bdg3.getSaturationPressure() == Approx(0.7867490)); */ } diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index 0962d6d1..a0697d1e 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -164,7 +164,8 @@ test('fan203 test', function (t) { }); test('getBaseGasDensity', function (t) { - t.plan(6); + //t.plan(6); + t.plan(16); t.type(bindings.getBaseGasDensityRelativeHumidity, 'function'); t.type(bindings.getBaseGasDensityDewPoint, 'function'); t.type(bindings.getBaseGasDensityWetBulb, 'function'); @@ -214,6 +215,28 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityWetBulb(inp); //t.equal(rnd(res), rnd(0.065456)); t.equal(rnd(res), rnd(0.0557205)); + + inp = { + dryBulbTemp: 123, + staticPressure: -17.6, + barometricPressure: 26.57, + gasDensity: 0.0547, + gasType: 'AIR', + inputType: 'relativeHumidity', + relativeHumidity: 35, + specificGravity: 1.05 + }; + res = bindings.getBaseGasDensityObj(inp); + t.equal(rnd(res.po), rnd(0.0564228)); + t.equal(rnd(res.pIn), rnd(25.27671)); + t.equal(rnd(res.satW), rnd(0.108296)); + t.equal(rnd(res.satDeg), rnd(0.314416)); + t.equal(rnd(res.humW), rnd(0.03405)); + t.equal(rnd(res.specVol), rnd(18.326807)); + t.equal(rnd(res.enthalpy), rnd(68.367639)); + t.equal(rnd(res.dewPoint), rnd(87.401991)); + t.equal(rnd(res.rh), rnd(0.35)); + t.equal(rnd(res.satPress), rnd(3.748405)); }); test('getVelocityPressureData', function (t) { From 39be2a2a9453580e08e6d1c4e2118a15cb373074 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 19 Mar 2020 09:27:19 -0400 Subject: [PATCH 178/217] Added debugging code --- Docker/Dockerfile | 1 + include/fans/Fan203.h | 27 +++++++++++++++++++++++---- tests/Fan.unit.cpp | 8 ++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index ad951e95..8f52359e 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -142,6 +142,7 @@ RUN ./bin/amo_tools_suite_tests #RUN npm run at #RUN doxygen Doxyfile.in +RUN cat debug.txt #-------------------------------------------------------------- #WORKDIR /home/ diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 9fce1114..6c046d0a 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -266,9 +266,25 @@ class BaseGasDensity */ double calculateSaturationPressure(double dryBulbTemp) const { - double const C1 = -5674.5359, C2 = 6.3925247, C3 = -0.009677843, C4 = 0.00000062215701; - double const C5 = 2.0747825 * std::pow(10, -9), C6 = -9.484024 * std::pow(10, -13), C7 = 4.1635019; - double const C8 = -5800.2206, C9 = 1.3914093, C10 = -0.048640239, C11 = 0.000041764768, C12 = -0.000000014452093, C13 = 6.5459673; + double const C1 = -5674.5359; + double const C2 = 6.3925247; + double const C3 = -0.009677843; + double const C4 = 0.00000062215701; + //double const C4 = 6.22157 * std::pow(10, -7); + double const C5 = 2.0747825 * std::pow(10, -9); + //double const C5 = 2.07478 * std::pow(10, -9); + double const C6 = -9.484024 * std::pow(10, -13); + //double const C6 = -9.48402 * std::pow(10, -13); + double const C7 = 4.1635019; + double const C8 = -5800.2206; + double const C9 = 1.3914093; + //double const C9 = 1.3914993; + double const C10 = -0.048640239; + double const C11 = 0.000041764768; + //double const C11 = 4.17648 * std::pow(10, -5); + double const C12 = -0.000000014452093; + //double const C12 = -1.44521 * std::pow(10, -8); + double const C13 = 6.5459673; double const tKelvin = (dryBulbTemp + 459.67) * 0.555556; @@ -307,10 +323,12 @@ class BaseGasDensity const double cpGas) const { double const nMol = 0.62198; + //double const nMol = 0.5831677622; //double const pAtm = 29.9213 / pbo, nMol = 18.02 / (g * 28.98); double const psatDb = calculateSaturationPressure(dryBulbTemp); // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); + //double const psatWb = 0.5112186; double const wStar = nMol * psatWb / (pbo - psatWb); //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); @@ -340,7 +358,8 @@ class BaseGasDensity satW = 0.62198 * satPress / (pIn - satPress); satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); humW = satDeg * satW; - specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); + //specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); + specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.4911541); po = (1 / specVol) * (1 + humW); enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 78ebaaed..191b9d9f 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -168,7 +168,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { 70, 26.62, 29.92, 60, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); //CHECK(bdg.getGasDensity() == Approx(0.08143315)); - + /* CHECK(bdg.getGasDensity() == Approx(0.0794202473)); CHECK(bdg.getAbsolutePressureIn() == Approx(31.8761011803)); CHECK(bdg.getSaturatedHumidityRatio() == Approx(0.014773)); @@ -179,11 +179,11 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg.getDewPoint() == Approx(55.5523108718)); CHECK(bdg.getRelativeHumidity() == Approx(0.60)); CHECK(bdg.getSaturationPressure() == Approx(0.7395925636)); - + */ auto const bdg2 = BaseGasDensity( 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 ); - + /* CHECK(bdg2.getGasDensity() == Approx(0.0794202473)); CHECK(bdg2.getAbsolutePressureIn() == Approx(31.8761011803)); CHECK(bdg2.getSaturatedHumidityRatio() == Approx(0.014773)); @@ -194,7 +194,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg2.getDewPoint() == Approx(55.5)); CHECK(bdg2.getRelativeHumidity() == Approx(0.6001754464)); CHECK(bdg2.getSaturationPressure() == Approx(0.7395925636)); - + */ auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 ); From 4fc95692a7673dfa224e554fd4d2fb451b787a41 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 20 Mar 2020 12:43:22 -0400 Subject: [PATCH 179/217] Continuing work on fan calcs --- include/fans/Fan203.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 6c046d0a..e6cc8d43 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -277,8 +277,8 @@ class BaseGasDensity //double const C6 = -9.48402 * std::pow(10, -13); double const C7 = 4.1635019; double const C8 = -5800.2206; - double const C9 = 1.3914093; - //double const C9 = 1.3914993; + //double const C9 = 1.3914093; + double const C9 = 1.3914993; double const C10 = -0.048640239; double const C11 = 0.000041764768; //double const C11 = 4.17648 * std::pow(10, -5); @@ -329,7 +329,7 @@ class BaseGasDensity // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); //double const psatWb = 0.5112186; - double const wStar = nMol * psatWb / (pbo - psatWb); + double const wStar = nMol * psatWb / (pbo + (pso / 13.608703) - psatWb); // pIn = pbo + (pso / 13.608703) //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); @@ -354,9 +354,11 @@ class BaseGasDensity */ void calculateFanAttributes(InputType const inputType, double const relativeHumidityOrDewPoint = -1) { + double const nMol = 0.62198; + pIn = pbo + (pso / 13.608703); - satW = 0.62198 * satPress / (pIn - satPress); - satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); + satW = nMol * satPress / (pIn - satPress); + satDeg = rh / ( 1 + ( 1 - rh) * satW / nMol); humW = satDeg * satW; //specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.4911541); @@ -365,7 +367,7 @@ class BaseGasDensity if(inputType != InputType::DewPoint) { - double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); + double const alpha = std::log(pIn * 0.4911541 * humW / (nMol + humW)); if(tdo < 32) { @@ -374,7 +376,8 @@ class BaseGasDensity } else { - dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow((pIn * 0.4911541 * humW / (0.62196 + humW)), 0.1984)); + //dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::exp(std::pow(alpha, 0.1984))); //(std::pow(std::exp(alpha), 0.1984)); //dewPoint = 2; } From 046d080cbcc76bbd9442d7deaff3599f50442b90 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 20 Mar 2020 14:42:19 -0400 Subject: [PATCH 180/217] Unit and acceptance tests are passing --- Docker/Dockerfile | 12 ++++---- include/fans/Fan203.h | 6 ++-- tests/Fan.unit.cpp | 67 +++++++++++++++++++++---------------------- tests/js/fanTest.js | 22 +++++++------- 4 files changed, 54 insertions(+), 53 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 8f52359e..22e186b3 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -133,16 +133,16 @@ RUN cmake --build . RUN ./bin/amo_tools_suite_tests -#RUN npm install +RUN npm install -#RUN node-gyp rebuild +RUN node-gyp rebuild -#RUN npm run test +RUN npm run test -#RUN npm run at +RUN npm run at -#RUN doxygen Doxyfile.in -RUN cat debug.txt +RUN doxygen Doxyfile.in +#RUN cat debug.txt #-------------------------------------------------------------- #WORKDIR /home/ diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index e6cc8d43..cf566cdb 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -323,17 +323,19 @@ class BaseGasDensity const double cpGas) const { double const nMol = 0.62198; + double const local_pIn = pbo + (pso / 13.608703); //double const nMol = 0.5831677622; //double const pAtm = 29.9213 / pbo, nMol = 18.02 / (g * 28.98); double const psatDb = calculateSaturationPressure(dryBulbTemp); // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); //double const psatWb = 0.5112186; - double const wStar = nMol * psatWb / (pbo + (pso / 13.608703) - psatWb); // pIn = pbo + (pso / 13.608703) + double const wStar = nMol * psatWb / (local_pIn - psatWb); // pIn = pbo + (pso / 13.608703) //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); - double const pV = pbo * w / (nMol + w); + //double const pV = pbo * w / (nMol + w); + double const pV = local_pIn * w / (nMol + w); std::ofstream fout; fout.open("debug.txt", std::ios::app); fout << "calculateRelativeHumidityFromWetBulb" << std::endl; diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 191b9d9f..6d5d99c0 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -168,46 +168,45 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { 70, 26.62, 29.92, 60, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); //CHECK(bdg.getGasDensity() == Approx(0.08143315)); - /* - CHECK(bdg.getGasDensity() == Approx(0.0794202473)); - CHECK(bdg.getAbsolutePressureIn() == Approx(31.8761011803)); - CHECK(bdg.getSaturatedHumidityRatio() == Approx(0.014773)); - CHECK(bdg.getDegreeOfSaturation() == Approx(0.5943528804)); - CHECK(bdg.getHumidityRatio() == Approx(0.0087806)); - CHECK(bdg.getSpecificVolume() == Approx(12.7018112191)); - CHECK(bdg.getEnthalpy() == Approx(26.87954206)); - CHECK(bdg.getDewPoint() == Approx(55.5523108718)); + + CHECK(bdg.getGasDensity() == Approx(0.0793577)); + CHECK(bdg.getAbsolutePressureIn() == Approx(31.8761)); + CHECK(bdg.getSaturatedHumidityRatio() == Approx(0.0147754)); + CHECK(bdg.getDegreeOfSaturation() == Approx(0.594352)); + CHECK(bdg.getHumidityRatio() == Approx(0.00878179)); + CHECK(bdg.getSpecificVolume() == Approx(12.7118)); + CHECK(bdg.getEnthalpy() == Approx(26.8804)); + CHECK(bdg.getDewPoint() == Approx(55.5539)); CHECK(bdg.getRelativeHumidity() == Approx(0.60)); - CHECK(bdg.getSaturationPressure() == Approx(0.7395925636)); - */ + CHECK(bdg.getSaturationPressure() == Approx(0.739659)); + auto const bdg2 = BaseGasDensity( 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 ); - /* - CHECK(bdg2.getGasDensity() == Approx(0.0794202473)); - CHECK(bdg2.getAbsolutePressureIn() == Approx(31.8761011803)); - CHECK(bdg2.getSaturatedHumidityRatio() == Approx(0.014773)); - CHECK(bdg2.getDegreeOfSaturation() == Approx(0.5945291299)); - CHECK(bdg2.getHumidityRatio() == Approx(0.0087806)); - CHECK(bdg2.getSpecificVolume() == Approx(12.7018112191)); - CHECK(bdg2.getEnthalpy() == Approx(26.882385744)); + + CHECK(bdg2.getGasDensity() == Approx(0.0793576)); + CHECK(bdg2.getAbsolutePressureIn() == Approx(31.8761)); + CHECK(bdg2.getSaturatedHumidityRatio() == Approx(0.0147754)); + CHECK(bdg2.getDegreeOfSaturation() == Approx(0.594529)); + CHECK(bdg2.getHumidityRatio() == Approx(0.00878439)); + CHECK(bdg2.getSpecificVolume() == Approx(12.7119)); + CHECK(bdg2.getEnthalpy() == Approx(26.8833)); CHECK(bdg2.getDewPoint() == Approx(55.5)); - CHECK(bdg2.getRelativeHumidity() == Approx(0.6001754464)); - CHECK(bdg2.getSaturationPressure() == Approx(0.7395925636)); - */ + CHECK(bdg2.getRelativeHumidity() == Approx(0.600175)); + CHECK(bdg2.getSaturationPressure() == Approx(0.739659)); + auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 ); - /* - CHECK(bdg3.getGasDensity() == Approx(0.079326234)); - CHECK(bdg3.getAbsolutePressureIn() == Approx(31.8761011803)); - CHECK(bdg3.getSaturatedHumidityRatio() == Approx(0.014773)); - CHECK(bdg3.getDegreeOfSaturation() == Approx(0.595)); - CHECK(bdg3.getHumidityRatio() == Approx(0.0087834)); - CHECK(bdg3.getSpecificVolume() == Approx(12.71)); - CHECK(bdg3.getEnthalpy() == Approx(26.39)); - CHECK(bdg3.getDewPoint() == Approx(55.51)); - CHECK(bdg3.getRelativeHumidity() == Approx(0.6002)); - CHECK(bdg3.getSaturationPressure() == Approx(0.7867490)); - */ + + CHECK(bdg3.getGasDensity() == Approx(0.0793575)); + CHECK(bdg3.getAbsolutePressureIn() == Approx(31.8761)); + CHECK(bdg3.getSaturatedHumidityRatio() == Approx(0.0147754)); + CHECK(bdg3.getDegreeOfSaturation() == Approx(0.594626)); + CHECK(bdg3.getHumidityRatio() == Approx(0.00878583)); + CHECK(bdg3.getSpecificVolume() == Approx(12.7119)); + CHECK(bdg3.getEnthalpy() == Approx(26.8848)); + CHECK(bdg3.getDewPoint() == Approx(55.5664)); + CHECK(bdg3.getRelativeHumidity() == Approx(0.600272)); + CHECK(bdg3.getSaturationPressure() == Approx(0.739659)); } diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index a0697d1e..e8e0a859 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -183,7 +183,7 @@ test('getBaseGasDensity', function (t) { var res = bindings.getBaseGasDensityRelativeHumidity(inp); //t.equal(rnd(res), rnd(0.06231117736966)); - t.equal(rnd(res), rnd(0.0564228)); + t.equal(rnd(res), rnd(0.056378)); inp = { dryBulbTemp: 123, @@ -198,7 +198,7 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityDewPoint(inp); //t.equal(rnd(res), rnd(0.06551801779516826)); - t.equal(rnd(res), rnd(0.057519)); + t.equal(rnd(res), rnd(0.057474)); inp = { dryBulbTemp: 123, @@ -214,7 +214,7 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityWetBulb(inp); //t.equal(rnd(res), rnd(0.065456)); - t.equal(rnd(res), rnd(0.0557205)); + t.equal(rnd(res), rnd(0.055653)); inp = { dryBulbTemp: 123, @@ -227,16 +227,16 @@ test('getBaseGasDensity', function (t) { specificGravity: 1.05 }; res = bindings.getBaseGasDensityObj(inp); - t.equal(rnd(res.po), rnd(0.0564228)); + t.equal(rnd(res.po), rnd(0.056378)); t.equal(rnd(res.pIn), rnd(25.27671)); - t.equal(rnd(res.satW), rnd(0.108296)); - t.equal(rnd(res.satDeg), rnd(0.314416)); - t.equal(rnd(res.humW), rnd(0.03405)); - t.equal(rnd(res.specVol), rnd(18.326807)); - t.equal(rnd(res.enthalpy), rnd(68.367639)); - t.equal(rnd(res.dewPoint), rnd(87.401991)); + t.equal(rnd(res.satW), rnd(0.108308)); + t.equal(rnd(res.satDeg), rnd(0.314413)); + t.equal(rnd(res.humW), rnd(0.034053)); + t.equal(rnd(res.specVol), rnd(18.341334)); + t.equal(rnd(res.enthalpy), rnd(68.371246)); + t.equal(rnd(res.dewPoint), rnd(87.403871)); t.equal(rnd(res.rh), rnd(0.35)); - t.equal(rnd(res.satPress), rnd(3.748405)); + t.equal(rnd(res.satPress), rnd(3.748742)); }); test('getVelocityPressureData', function (t) { From 22e3ab68dd6b66921509c2d6a685ebcc4fb5839b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 23 Mar 2020 10:14:02 -0400 Subject: [PATCH 181/217] Working on BaseGasDensity bindings --- bindings/fan.h | 30 ++++++++------- include/fans/Fan203.h | 88 +++++-------------------------------------- 2 files changed, 26 insertions(+), 92 deletions(-) diff --git a/bindings/fan.h b/bindings/fan.h index 23fd41a8..f129e19b 100644 --- a/bindings/fan.h +++ b/bindings/fan.h @@ -436,9 +436,8 @@ NAN_METHOD(fanResultsModified) // info.GetReturnValue().Set(r); // } -NAN_METHOD(getBaseGasDensityObj) +void SetBaseGasDensityData(Local & obj, const BaseGasDensity & bgd) { - // Local ??? Local po = Nan::New("po").ToLocalChecked(); Local pIn = Nan::New("pIn").ToLocalChecked(); Local satW = Nan::New("satW").ToLocalChecked(); @@ -450,6 +449,20 @@ NAN_METHOD(getBaseGasDensityObj) Local rh = Nan::New("rh").ToLocalChecked(); Local satPress = Nan::New("satPress").ToLocalChecked(); + Nan::Set(obj, po, Nan::New(bgd.getGasDensity())); + Nan::Set(obj, pIn, Nan::New(bgd.getAbsolutePressureIn())); + Nan::Set(obj, satW, Nan::New(bgd.getSaturatedHumidityRatio())); + Nan::Set(obj, satDeg, Nan::New(bgd.getDegreeOfSaturation())); + Nan::Set(obj, humW, Nan::New(bgd.getHumidityRatio())); + Nan::Set(obj, specVol, Nan::New(bgd.getSpecificVolume())); + Nan::Set(obj, enthalpy, Nan::New(bgd.getEnthalpy())); + Nan::Set(obj, dewPoint, Nan::New(bgd.getDewPoint())); + Nan::Set(obj, rh, Nan::New(bgd.getRelativeHumidity())); + Nan::Set(obj, satPress, Nan::New(bgd.getSaturationPressure())); +} + +NAN_METHOD(getBaseGasDensityObj) +{ Local obj = Nan::New(); inp = Nan::To(info[0]).ToLocalChecked(); @@ -466,7 +479,7 @@ NAN_METHOD(getBaseGasDensityObj) const double specificGravity = Get("specificGravity", inp); //Calculation procedure - auto bgd = BaseGasDensity( + BaseGasDensity bgd = BaseGasDensity( dryBulbTemp, staticPressure, barometricPressure, @@ -475,16 +488,7 @@ NAN_METHOD(getBaseGasDensityObj) inputType, specificGravity); - Nan::Set(obj, po, Nan::New(bgd.getGasDensity())); - Nan::Set(obj, pIn, Nan::New(bgd.getAbsolutePressureIn())); - Nan::Set(obj, satW, Nan::New(bgd.getSaturatedHumidityRatio())); - Nan::Set(obj, satDeg, Nan::New(bgd.getDegreeOfSaturation())); - Nan::Set(obj, humW, Nan::New(bgd.getHumidityRatio())); - Nan::Set(obj, specVol, Nan::New(bgd.getSpecificVolume())); - Nan::Set(obj, enthalpy, Nan::New(bgd.getEnthalpy())); - Nan::Set(obj, dewPoint, Nan::New(bgd.getDewPoint())); - Nan::Set(obj, rh, Nan::New(bgd.getRelativeHumidity())); - Nan::Set(obj, satPress, Nan::New(bgd.getSaturationPressure())); + SetBaseGasDensityData(obj, bgd); //NAN return object info.GetReturnValue().Set(obj); diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index cf566cdb..0aa7d7bd 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -106,12 +106,9 @@ class BaseGasDensity throw std::runtime_error("The wrong constructor for BaseGasDensity was called here - check inputType field"); } - /* - double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); - po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh * rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); - */ - calculateFanAttributes(inputType, relativeHumidityOrDewPoint); + + /* std::ofstream fout; fout.open("debug.txt", std::ios::app); fout << "po: " << po << std::endl; @@ -126,39 +123,7 @@ class BaseGasDensity fout << "satPress: " << satPress << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); - - /* - pIn = pbo + (pso / 13.608703); - satW = 0.62198 * satPress / (pIn - satPress); - satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); - humW = satDeg * satW; - specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); - po = (1 / specVol) * (1 + humW); - enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); - - if(inputType != InputType::DewPoint) - { - double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); - - if(tdo < 32) - { - dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; - //dewPoint = 1; - } - else - { - dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); - //dewPoint = 2; - } - - } - else - { - dewPoint = relativeHumidityOrDewPoint; - //dewPoint = 3; - } */ - } BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, @@ -170,12 +135,10 @@ class BaseGasDensity throw std::runtime_error("The wrong constructor for BaseGasDensity was called - check inputType field"); satPress = calculateSaturationPressure(tdo); rh = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); - /* - double const rhRatio = calculateRatioRH(tdo, rh, pbo, specificGravity); - po = (((pbo + (pso / 13.6)) - satPress * rh) * g + satPress * rh + rhRatio) / ((21.85 / (g * 29.98)) * (tdo + 459.7)); - */ calculateFanAttributes(inputType); + + /* std::ofstream fout; fout.open("debug.txt", std::ios::app); fout << "Wet Bulb" << std::endl; @@ -191,28 +154,6 @@ class BaseGasDensity fout << "satPress: " << satPress << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); - - /* - pIn = pbo + (pso / 13.608703); - satW = 0.62198 * satPress / (pIn - satPress); - satDeg = rh / ( 1 + ( 1 - rh) * satW / 0.62198); - humW = satDeg * satW; - specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); - po = (1 / specVol) * (1 + humW); - enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); - - double const alpha = std::log(pIn * 0.4911541 * humW / (0.62196 + humW)); - - if(tdo < 32) - { - dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; - //dewPoint = 1; - } - else - { - dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow(std::exp(alpha), 0.1984)); - //dewPoint = 2; - } */ } @@ -270,20 +211,14 @@ class BaseGasDensity double const C2 = 6.3925247; double const C3 = -0.009677843; double const C4 = 0.00000062215701; - //double const C4 = 6.22157 * std::pow(10, -7); double const C5 = 2.0747825 * std::pow(10, -9); - //double const C5 = 2.07478 * std::pow(10, -9); double const C6 = -9.484024 * std::pow(10, -13); - //double const C6 = -9.48402 * std::pow(10, -13); double const C7 = 4.1635019; double const C8 = -5800.2206; - //double const C9 = 1.3914093; double const C9 = 1.3914993; double const C10 = -0.048640239; double const C11 = 0.000041764768; - //double const C11 = 4.17648 * std::pow(10, -5); double const C12 = -0.000000014452093; - //double const C12 = -1.44521 * std::pow(10, -8); double const C13 = 6.5459673; double const tKelvin = (dryBulbTemp + 459.67) * 0.555556; @@ -324,18 +259,16 @@ class BaseGasDensity { double const nMol = 0.62198; double const local_pIn = pbo + (pso / 13.608703); - //double const nMol = 0.5831677622; //double const pAtm = 29.9213 / pbo, nMol = 18.02 / (g * 28.98); double const psatDb = calculateSaturationPressure(dryBulbTemp); // double const wSat = nMol * psatDb / (pAtm - psatDb); double const psatWb = calculateSaturationPressure(wetBulbTemp); - //double const psatWb = 0.5112186; - double const wStar = nMol * psatWb / (local_pIn - psatWb); // pIn = pbo + (pso / 13.608703) - //double const w = ((1061 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1061 + (0.444 * dryBulbTemp) - wetBulbTemp); + double const wStar = nMol * psatWb / (local_pIn - psatWb); double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); - //double const pV = pbo * w / (nMol + w); double const pV = local_pIn * w / (nMol + w); + + /* std::ofstream fout; fout.open("debug.txt", std::ios::app); fout << "calculateRelativeHumidityFromWetBulb" << std::endl; @@ -345,6 +278,8 @@ class BaseGasDensity fout << "w: " << w << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); + */ + return pV / psatDb; } /** @@ -362,7 +297,6 @@ class BaseGasDensity satW = nMol * satPress / (pIn - satPress); satDeg = rh / ( 1 + ( 1 - rh) * satW / nMol); humW = satDeg * satW; - //specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.491541); specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.4911541); po = (1 / specVol) * (1 + humW); enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); @@ -374,20 +308,16 @@ class BaseGasDensity if(tdo < 32) { dewPoint = 90.12 + 26.412 * alpha + 0.8927 * alpha * alpha; - //dewPoint = 1; } else { dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow((pIn * 0.4911541 * humW / (0.62196 + humW)), 0.1984)); - //dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::exp(std::pow(alpha, 0.1984))); //(std::pow(std::exp(alpha), 0.1984)); - //dewPoint = 2; } } else { dewPoint = relativeHumidityOrDewPoint; - //dewPoint = 3; } } From 3182890246d841639bac089c51d8cf4b9f2efc4f Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 23 Mar 2020 16:59:23 -0400 Subject: [PATCH 182/217] Reworked BaseGasDensity bindings to return objects rather than just the density value alone --- bindings/fan.cpp | 3 -- bindings/fan.h | 84 ++++++++++++----------------- include/fans/Fan203.h | 1 + tests/js/fanTest.js | 120 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 134 insertions(+), 74 deletions(-) diff --git a/bindings/fan.cpp b/bindings/fan.cpp index 3d00ae9e..bf546a23 100644 --- a/bindings/fan.cpp +++ b/bindings/fan.cpp @@ -15,9 +15,6 @@ NAN_MODULE_INIT(InitFans) { Nan::Set(target, New("fan203").ToLocalChecked(), GetFunction(New(fan203)).ToLocalChecked()); - Nan::Set(target, New("getBaseGasDensityObj").ToLocalChecked(), - GetFunction(New(getBaseGasDensityObj)).ToLocalChecked()); - Nan::Set(target, New("getBaseGasDensityRelativeHumidity").ToLocalChecked(), GetFunction(New(getBaseGasDensityRelativeHumidity)).ToLocalChecked()); diff --git a/bindings/fan.h b/bindings/fan.h index f129e19b..4d5f7bf8 100644 --- a/bindings/fan.h +++ b/bindings/fan.h @@ -460,8 +460,7 @@ void SetBaseGasDensityData(Local & obj, const BaseGasDensity & bgd) Nan::Set(obj, rh, Nan::New(bgd.getRelativeHumidity())); Nan::Set(obj, satPress, Nan::New(bgd.getSaturationPressure())); } - -NAN_METHOD(getBaseGasDensityObj) +NAN_METHOD(getBaseGasDensityRelativeHumidity) { Local obj = Nan::New(); @@ -489,50 +488,19 @@ NAN_METHOD(getBaseGasDensityObj) specificGravity); SetBaseGasDensityData(obj, bgd); - + //NAN return object info.GetReturnValue().Set(obj); - } - catch (std::runtime_error const &e) - { - info.GetReturnValue().Set(0); - std::string const what = e.what(); - ThrowError(std::string("std::runtime_error thrown in getBaseGasDensityRelativeHumidity - fan.h: " + what).c_str()); - } -} - -NAN_METHOD(getBaseGasDensityRelativeHumidity) -{ - inp = Nan::To(info[0]).ToLocalChecked(); - r = Nan::New(); - try - { - //NAN data init - const double dryBulbTemp = Get("dryBulbTemp", inp); - const double staticPressure = Get("staticPressure", inp); - const double barometricPressure = Get("barometricPressure", inp); - const double relativeHumidity = Get("relativeHumidity", inp); - BaseGasDensity::GasType gasType = getGasType(inp); - BaseGasDensity::InputType inputType = getInputType(inp); - const double specificGravity = Get("specificGravity", inp); - - //Calculation procedure - double result = BaseGasDensity( - dryBulbTemp, - staticPressure, - barometricPressure, - relativeHumidity, - gasType, - inputType, - specificGravity) - .getGasDensity(); //NAN return single value - info.GetReturnValue().Set(result); + //info.GetReturnValue().Set(result); } catch (std::runtime_error const &e) { - info.GetReturnValue().Set(0); + Local obj_err = Nan::New(); + BaseGasDensity bgd_err = BaseGasDensity(0, 0, 0, 0, BaseGasDensity::GasType::OTHERGAS); + SetBaseGasDensityData(obj_err, bgd_err); + info.GetReturnValue().Set(obj_err); std::string const what = e.what(); ThrowError(std::string("std::runtime_error thrown in getBaseGasDensityRelativeHumidity - fan.h: " + what).c_str()); } @@ -540,6 +508,8 @@ NAN_METHOD(getBaseGasDensityRelativeHumidity) NAN_METHOD(getBaseGasDensityDewPoint) { + Local obj = Nan::New(); + inp = Nan::To(info[0]).ToLocalChecked(); r = Nan::New(); try @@ -554,22 +524,29 @@ NAN_METHOD(getBaseGasDensityDewPoint) const double specificGravity = Get("specificGravity", inp); //Calculation procedure - double result = BaseGasDensity( + BaseGasDensity bgd = BaseGasDensity( dryBulbTemp, staticPressure, barometricPressure, dewPoint, gasType, inputType, - specificGravity) - .getGasDensity(); + specificGravity); + + SetBaseGasDensityData(obj, bgd); + + //NAN return object + info.GetReturnValue().Set(obj); //NAN return single value - info.GetReturnValue().Set(result); + //info.GetReturnValue().Set(result); } catch (std::runtime_error const &e) { - info.GetReturnValue().Set(0); + Local obj_err = Nan::New(); + BaseGasDensity bgd_err = BaseGasDensity(0, 0, 0, 0, BaseGasDensity::GasType::OTHERGAS); + SetBaseGasDensityData(obj_err, bgd_err); + info.GetReturnValue().Set(obj_err); std::string const what = e.what(); ThrowError(std::string("std::runtime_error thrown in getBaseGasDensityDewPoint - fan.h: " + what).c_str()); } @@ -577,6 +554,8 @@ NAN_METHOD(getBaseGasDensityDewPoint) NAN_METHOD(getBaseGasDensityWetBulb) { + Local obj = Nan::New(); + inp = Nan::To(info[0]).ToLocalChecked(); r = Nan::New(); try @@ -592,7 +571,7 @@ NAN_METHOD(getBaseGasDensityWetBulb) const double specificHeatGas = Get("specificHeatGas", inp); //Calculation procedure - double result = BaseGasDensity( + BaseGasDensity bgd = BaseGasDensity( dryBulbTemp, staticPressure, barometricPressure, @@ -600,15 +579,22 @@ NAN_METHOD(getBaseGasDensityWetBulb) gasType, inputType, specificGravity, - specificHeatGas) - .getGasDensity(); + specificHeatGas); + + SetBaseGasDensityData(obj, bgd); + + //NAN return object + info.GetReturnValue().Set(obj); //NAN return single value - info.GetReturnValue().Set(result); + //info.GetReturnValue().Set(result); } catch (std::runtime_error const &e) { - info.GetReturnValue().Set(0); + Local obj_err = Nan::New(); + BaseGasDensity bgd_err = BaseGasDensity(0, 0, 0, 0, BaseGasDensity::GasType::OTHERGAS); + SetBaseGasDensityData(obj_err, bgd_err); + info.GetReturnValue().Set(obj_err); std::string const what = e.what(); ThrowError(std::string("std::runtime_error thrown in getBaseGasDensityWetBulb - fan.h: " + what).c_str()); } diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 0aa7d7bd..ff577983 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -56,6 +56,7 @@ class BaseGasDensity RelativeHumidity, WetBulbTemp }; + /** * @param dryBulbTemp double, temperature of inputted air in °F * @param staticPressure const, double, pressure in Hg diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index e8e0a859..2a871fa5 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -165,7 +165,7 @@ test('fan203 test', function (t) { test('getBaseGasDensity', function (t) { //t.plan(6); - t.plan(16); + t.plan(63); t.type(bindings.getBaseGasDensityRelativeHumidity, 'function'); t.type(bindings.getBaseGasDensityDewPoint, 'function'); t.type(bindings.getBaseGasDensityWetBulb, 'function'); @@ -183,7 +183,39 @@ test('getBaseGasDensity', function (t) { var res = bindings.getBaseGasDensityRelativeHumidity(inp); //t.equal(rnd(res), rnd(0.06231117736966)); - t.equal(rnd(res), rnd(0.056378)); + t.equal(rnd(res.po), rnd(0.056378)); + t.equal(rnd(res.pIn), rnd(25.27671)); + t.equal(rnd(res.satW), rnd(0.108308)); + t.equal(rnd(res.satDeg), rnd(0.314413)); + t.equal(rnd(res.humW), rnd(0.034053)); + t.equal(rnd(res.specVol), rnd(18.341334)); + t.equal(rnd(res.enthalpy), rnd(68.371246)); + t.equal(rnd(res.dewPoint), rnd(87.403871)); + t.equal(rnd(res.rh), rnd(0.35)); + t.equal(rnd(res.satPress), rnd(3.748742)); + + inp = { + dryBulbTemp: 70, + staticPressure: 26.62, + barometricPressure: 29.92, + gasDensity: 0.0, + gasType: 'AIR', + inputType: 'relativeHumidity', + relativeHumidity: 60, + specificGravity: 1 + }; + + res = bindings.getBaseGasDensityRelativeHumidity(inp); + t.equal(rnd(res.po), rnd(0.0793577)); + t.equal(rnd(res.pIn), rnd(31.876101)); + t.equal(rnd(res.satW), rnd(0.0147754)); + t.equal(rnd(res.satDeg), rnd(0.594352)); + t.equal(rnd(res.humW), rnd(0.00878179)); + t.equal(rnd(res.specVol), rnd(12.711833)); + t.equal(rnd(res.enthalpy), rnd(26.880417)); + t.equal(rnd(res.dewPoint), rnd(55.553919)); + t.equal(rnd(res.rh), rnd(0.60)); + t.equal(rnd(res.satPress), rnd(0.739659)); inp = { dryBulbTemp: 123, @@ -198,7 +230,39 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityDewPoint(inp); //t.equal(rnd(res), rnd(0.06551801779516826)); - t.equal(rnd(res), rnd(0.057474)); + t.equal(rnd(res.po), rnd(0.057474)); + t.equal(rnd(res.pIn), rnd(25.27671)); + t.equal(rnd(res.satW), rnd(0.108308)); + t.equal(rnd(res.satDeg), rnd(0.00873)); + t.equal(rnd(res.humW), rnd(0.000946)); + t.equal(rnd(res.specVol), rnd(17.415694)); + t.equal(rnd(res.enthalpy), rnd(31.435888)); + t.equal(rnd(res.dewPoint), rnd(0.35)); + t.equal(rnd(res.rh), rnd(0.010235)); + t.equal(rnd(res.satPress), rnd(3.748742)); + + inp = { + dryBulbTemp: 70, + staticPressure: 26.62, + barometricPressure: 29.92, + gasDensity: 0.0, + gasType: 'AIR', + inputType: 'dewPoint', + dewPoint: 55.5, + specificGravity: 1 + }; + + res = bindings.getBaseGasDensityDewPoint(inp); + t.equal(rnd(res.po), rnd(0.0793576)); + t.equal(rnd(res.pIn), rnd(31.876101)); + t.equal(rnd(res.satW), rnd(0.0147754)); + t.equal(rnd(res.satDeg), rnd(0.594529)); + t.equal(rnd(res.humW), rnd(0.00878439)); + t.equal(rnd(res.specVol), rnd(12.711886)); + t.equal(rnd(res.enthalpy), rnd(26.883261)); + t.equal(rnd(res.dewPoint), rnd(55.5)); + t.equal(rnd(res.rh), rnd(0.600175)); + t.equal(rnd(res.satPress), rnd(0.739659)); inp = { dryBulbTemp: 123, @@ -214,29 +278,41 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityWetBulb(inp); //t.equal(rnd(res), rnd(0.065456)); - t.equal(rnd(res), rnd(0.055653)); + t.equal(rnd(res.po), rnd(0.055653)); + t.equal(rnd(res.pIn), rnd(25.27671)); + t.equal(rnd(res.satW), rnd(0.108308)); + t.equal(rnd(res.satDeg), rnd(0.535317)); + t.equal(rnd(res.humW), rnd(0.057979)); + t.equal(rnd(res.specVol), rnd(19.010256)); + t.equal(rnd(res.enthalpy), rnd(95.062901)); + t.equal(rnd(res.dewPoint), rnd(103.567304)); + t.equal(rnd(res.rh), rnd(0.574939)); + t.equal(rnd(res.satPress), rnd(3.748742)); inp = { - dryBulbTemp: 123, - staticPressure: -17.6, - barometricPressure: 26.57, - gasDensity: 0.0547, + dryBulbTemp: 70, + staticPressure: 26.62, + barometricPressure: 29.92, + gasDensity: 0.0, gasType: 'AIR', - inputType: 'relativeHumidity', - relativeHumidity: 35, - specificGravity: 1.05 + inputType: 'wetBulb', + wetBulbTemp: 61.2, + specificGravity: 1, + specificHeatGas: 0.24 }; - res = bindings.getBaseGasDensityObj(inp); - t.equal(rnd(res.po), rnd(0.056378)); - t.equal(rnd(res.pIn), rnd(25.27671)); - t.equal(rnd(res.satW), rnd(0.108308)); - t.equal(rnd(res.satDeg), rnd(0.314413)); - t.equal(rnd(res.humW), rnd(0.034053)); - t.equal(rnd(res.specVol), rnd(18.341334)); - t.equal(rnd(res.enthalpy), rnd(68.371246)); - t.equal(rnd(res.dewPoint), rnd(87.403871)); - t.equal(rnd(res.rh), rnd(0.35)); - t.equal(rnd(res.satPress), rnd(3.748742)); + + res = bindings.getBaseGasDensityWetBulb(inp); + t.equal(rnd(res.po), rnd(0.0793575)); + t.equal(rnd(res.pIn), rnd(31.876101)); + t.equal(rnd(res.satW), rnd(0.0147754)); + t.equal(rnd(res.satDeg), rnd(0.594626)); + t.equal(rnd(res.humW), rnd(0.00878583)); + t.equal(rnd(res.specVol), rnd(12.711914)); + t.equal(rnd(res.enthalpy), rnd(26.884828)); + t.equal(rnd(res.dewPoint), rnd(55.566384)); + t.equal(rnd(res.rh), rnd(0.600272)); + t.equal(rnd(res.satPress), rnd(0.739659)); + }); test('getVelocityPressureData', function (t) { From 23c983360bc6af0415bbc4cab7149cfdccffac40 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 24 Mar 2020 09:09:24 -0400 Subject: [PATCH 183/217] Updated Doxygen documentation --- include/fans/Fan203.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index ff577983..c7729907 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -78,13 +78,16 @@ class BaseGasDensity * @param gasType, double, gas, type of gas, unitless * @param inputType const, type of input, unitless * @param specificGravity, double, const, specific gravity, unitless - * @return pIn double, Absolute Pressure In in in Hg + * @return po double, density of the gas in pounds per sqft, lb/scf + * @return pIn double, Absolute Pressure In in in Hg XXX * @return satW double, Saturated Humidity Ratio, unitless * @return satDeg double, Degree of Saturation, unitless * @return humW double, Humidity Ratio, unitless * @return specVol double, Specific Volume, ft^3/lb + * @return entropy double, Entropy, B/lb + * @return dewPoint double, Dewpoint, deg F + * @return rh double, Relative Humidity, % * @return satPress double, Saturation Pressure, in Hg - * @return density double, density of the gas in pounds per sqft, lb/scf */ // TODO ensure correctness BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, From ae49c6afc718d6df57418032d1361ef712984ae3 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 24 Mar 2020 11:57:37 -0400 Subject: [PATCH 184/217] Added EstimateFLA unit test --- CMakeLists.txt | 3 ++- tests/EstimateFLA.unit.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/EstimateFLA.unit.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ad83ca7..169b287a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,7 +439,8 @@ set(TEST_FILES tests/steamapi/HeaderInput.unit.cpp tests/steamapi/OperationsInput.unit.cpp tests/steamapi/SteamModeler.unit.cpp - tests/steamapi/TurbineInput.unit.cpp) + tests/steamapi/TurbineInput.unit.cpp + tests/EstimateFLA.unit.cpp) #find_package(PythonInterp 2.7 REQUIRED) #execute_process( COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/seed_database.py" "${CMAKE_DATABASE_OUTPUT_DIRECTORY}/amo_tools_suite.db") diff --git a/tests/EstimateFLA.unit.cpp b/tests/EstimateFLA.unit.cpp new file mode 100644 index 00000000..230dca44 --- /dev/null +++ b/tests/EstimateFLA.unit.cpp @@ -0,0 +1,9 @@ +#include "catch.hpp" +#include +#include + + +TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { + //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460).calculate() == Approx(227.3)); + //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460).calculate() == Approx(228.4)); +} \ No newline at end of file From 94a86e856257c3a6b926d83ac067f1797ae32850 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 24 Mar 2020 14:22:44 -0400 Subject: [PATCH 185/217] Upddated EstimateFLA unit test --- Docker/Dockerfile | 10 ++++++---- tests/EstimateFLA.unit.cpp | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index ae3d5b6a..3825cd0a 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -133,13 +133,15 @@ RUN cmake --build . RUN ./bin/amo_tools_suite_tests -RUN npm install +#RUN npm install -RUN node-gyp rebuild +#RUN node-gyp rebuild -RUN npm run test +#RUN npm run test -RUN npm run at +#RUN npm run at + +RUN cat debug.txt #-------------------------------------------------------------- #WORKDIR /home/ diff --git a/tests/EstimateFLA.unit.cpp b/tests/EstimateFLA.unit.cpp index 230dca44..a1f6e4b4 100644 --- a/tests/EstimateFLA.unit.cpp +++ b/tests/EstimateFLA.unit.cpp @@ -1,9 +1,38 @@ #include "catch.hpp" #include +//#include #include +#include TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { - //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460).calculate() == Approx(227.3)); - //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460).calculate() == Approx(228.4)); + auto fla1 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460); + auto fla2 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460); + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + auto results1 = fla1.calculate(); + auto results2 = fla2.calculate(); + fout << "EstimateFLA.unit.cpp" << std::endl; + fout << "------------------------" << std::endl; + fout << "results1:" << std::endl; + fout << "{"; + for (const double &result : results1) + { + fout << result << ", "; + } + fout << "}"; + fout << std::endl; + fout << "results2:" << std::endl; + fout << "{"; + for (const double &result : results2) + { + fout << result << ", "; + } + fout << "}"; + fout << std::endl; + fout << "End" << std::endl; + fout << "------------------------" << std::endl; + fout.close(); + //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460).calculate() == Approx(227.3)); + //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460).calculate() == Approx(228.4)); } \ No newline at end of file From befd49b3efe3f2024b0650541072ac3f90fdab95 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 24 Mar 2020 15:00:26 -0400 Subject: [PATCH 186/217] Updated unit test --- src/calculator/motor/EstimateFLA.cpp | 1 + tests/EstimateFLA.unit.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/calculator/motor/EstimateFLA.cpp b/src/calculator/motor/EstimateFLA.cpp index 37f68b56..6e7e94ab 100644 --- a/src/calculator/motor/EstimateFLA.cpp +++ b/src/calculator/motor/EstimateFLA.cpp @@ -5,6 +5,7 @@ * @author Subhankar Mishra (mishras) * @author Gina Accawi (accawigk) * @author Preston Shires (pshires) (Refactoring mostly) + * @author Colin Causey (causeyc) * @bug No known bugs. * */ diff --git a/tests/EstimateFLA.unit.cpp b/tests/EstimateFLA.unit.cpp index a1f6e4b4..e4d7819d 100644 --- a/tests/EstimateFLA.unit.cpp +++ b/tests/EstimateFLA.unit.cpp @@ -8,6 +8,7 @@ TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { auto fla1 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460); auto fla2 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460); + std::ofstream fout; fout.open("debug.txt", std::ios::app); auto results1 = fla1.calculate(); @@ -30,9 +31,16 @@ TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { } fout << "}"; fout << std::endl; + auto estFLA1 = fla1.getEstimatedFLA(); + auto estFLA2 = fla2.getEstimatedFLA(); + fout << "estFLA1: " << estFLA1 << std::endl; + fout << "estFLA2: " << estFLA2 << std::endl; fout << "End" << std::endl; fout << "------------------------" << std::endl; fout.close(); + + CHECK(estFLA1 == Approx(228.4)); + CHECK(estFLA2 == Approx(227.3)); //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460).calculate() == Approx(227.3)); //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460).calculate() == Approx(228.4)); } \ No newline at end of file From 70e75e5a6f850b8d868521198143ca75b4a59ec7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 24 Mar 2020 15:44:18 -0400 Subject: [PATCH 187/217] Updated EstimateFLA.cpp --- src/calculator/motor/EstimateFLA.cpp | 33 ++++++++++++++++++++++++++++ tests/EstimateFLA.unit.cpp | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/calculator/motor/EstimateFLA.cpp b/src/calculator/motor/EstimateFLA.cpp index 6e7e94ab..1014c9f9 100644 --- a/src/calculator/motor/EstimateFLA.cpp +++ b/src/calculator/motor/EstimateFLA.cpp @@ -226,6 +226,38 @@ std::array EstimateFLA::calculate() { * 3. Divide the selected (EE or SE) efficiency by the specified efficiency and then multiply that by the FLA for the corresponding selection. */ + auto const seeffVal = MotorEfficiency(lineFrequency, motorRPM, Motor::EfficiencyClass::STANDARD, + motorRatedPower).calculate(1, specifiedEfficiency); + + auto const eeeffVal = MotorEfficiency(lineFrequency, motorRPM, Motor::EfficiencyClass::ENERGY_EFFICIENT, + motorRatedPower).calculate(1, specifiedEfficiency); + + if (std::fabs(seeffVal - specifiedEfficiency) < std::fabs(eeeffVal - specifiedEfficiency)) + { + // SE is the nominal efficiency + estimatedFLA = adjustForVoltage(seFLAValue * plMultiplier[4], seeffVal); + return { + { + seFLAValue * plMultiplier[0], seFLAValue * plMultiplier[1], seFLAValue * plMultiplier[2], + seFLAValue * plMultiplier[3], seFLAValue * plMultiplier[4], seFLAValue * plMultiplier[5] + } + }; + } + else + { + /// EE is the nominal efficiency + estimatedFLA = adjustForVoltage(eeFLAValue * plMultiplier[4], eeeffVal); + return { + { + eeFLAValue * plMultiplier[0], eeFLAValue * plMultiplier[1], eeFLAValue * plMultiplier[2], + eeFLAValue * plMultiplier[3], eeFLAValue * plMultiplier[4], eeFLAValue * plMultiplier[5] + } + }; + } + } + return {}; + +/* // specifiedEfficiency = 95; // commented out due to this not making sense if (std::fabs(eeFLAValue * plMultiplier[4] - specifiedEfficiency) > std::fabs(seFLAValue * plMultiplier[4] - specifiedEfficiency)) { @@ -253,4 +285,5 @@ std::array EstimateFLA::calculate() { } } return {}; +*/ } diff --git a/tests/EstimateFLA.unit.cpp b/tests/EstimateFLA.unit.cpp index e4d7819d..0d468269 100644 --- a/tests/EstimateFLA.unit.cpp +++ b/tests/EstimateFLA.unit.cpp @@ -8,7 +8,7 @@ TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { auto fla1 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460); auto fla2 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460); - + std::ofstream fout; fout.open("debug.txt", std::ios::app); auto results1 = fla1.calculate(); From fa395fb9e1822a5b64915d4f159c9e5592eb7c85 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 25 Mar 2020 10:55:18 -0400 Subject: [PATCH 188/217] Unit tests are all passing --- CMakeLists.txt | 3 +- Docker/Dockerfile | 13 ++++---- Docker/docker_commands.txt | 11 +++++-- src/calculator/motor/EstimateFLA.cpp | 33 ++------------------ tests/EstimateFLA.unit.cpp | 46 ---------------------------- tests/Results.unit.cpp | 18 ++++++++--- 6 files changed, 32 insertions(+), 92 deletions(-) delete mode 100644 tests/EstimateFLA.unit.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 169b287a..9ad83ca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,8 +439,7 @@ set(TEST_FILES tests/steamapi/HeaderInput.unit.cpp tests/steamapi/OperationsInput.unit.cpp tests/steamapi/SteamModeler.unit.cpp - tests/steamapi/TurbineInput.unit.cpp - tests/EstimateFLA.unit.cpp) + tests/steamapi/TurbineInput.unit.cpp) #find_package(PythonInterp 2.7 REQUIRED) #execute_process( COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/seed_database.py" "${CMAKE_DATABASE_OUTPUT_DIRECTORY}/amo_tools_suite.db") diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 3825cd0a..5ab0c0cb 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -133,15 +133,16 @@ RUN cmake --build . RUN ./bin/amo_tools_suite_tests -#RUN npm install +RUN npm install -#RUN node-gyp rebuild +RUN node-gyp rebuild -#RUN npm run test +RUN npm run test -#RUN npm run at +RUN npm run at -RUN cat debug.txt +RUN doxygen Doxyfile.in +#RUN cat debug.txt #-------------------------------------------------------------- -#WORKDIR /home/ +#WORKDIR /home/ \ No newline at end of file diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt index 55684b2f..ec923b52 100644 --- a/Docker/docker_commands.txt +++ b/Docker/docker_commands.txt @@ -1,12 +1,20 @@ docker image build -f Docker/Dockerfile -t comma64/ornl:amo-tools-suite . docker run -t -d --name amo-suite comma64/ornl:amo-tools-suite + +# Mount a host directory to persist source code and builds +docker run -t -d -v "/home/81c/AMO/src:/home/AMO/src/" --name amo-suite comma64/ornl:amo-tools-suite + + docker exec -it amo-suite /bin/bash + docker container rm --force amo-suite +docker rmi comma64/ornl:amo-tools-suite docker login docker push comma64/ornl:amo-tools-suite - +PowerShell (remove all images): +docker rmi $(docker images -q) docker stop $(docker ps -aq) 2>/dev/null || true docker rm $(docker ps -a -q) 2>/dev/null|| true @@ -33,4 +41,3 @@ npm run test npm run at #-------------------------------------------------------------- - diff --git a/src/calculator/motor/EstimateFLA.cpp b/src/calculator/motor/EstimateFLA.cpp index 1014c9f9..4fa52a5d 100644 --- a/src/calculator/motor/EstimateFLA.cpp +++ b/src/calculator/motor/EstimateFLA.cpp @@ -15,6 +15,7 @@ #include "calculator/motor/EstimateFLA.h" #include "calculator/motor/MotorEfficiency.h" #include "calculator/motor/Poles.h" +#include /** * Estimating FLA methodology @@ -232,7 +233,7 @@ std::array EstimateFLA::calculate() { auto const eeeffVal = MotorEfficiency(lineFrequency, motorRPM, Motor::EfficiencyClass::ENERGY_EFFICIENT, motorRatedPower).calculate(1, specifiedEfficiency); - if (std::fabs(seeffVal - specifiedEfficiency) < std::fabs(eeeffVal - specifiedEfficiency)) + if (std::fabs(seeffVal - (specifiedEfficiency / 100)) < std::fabs(eeeffVal - (specifiedEfficiency / 100))) { // SE is the nominal efficiency estimatedFLA = adjustForVoltage(seFLAValue * plMultiplier[4], seeffVal); @@ -256,34 +257,4 @@ std::array EstimateFLA::calculate() { } } return {}; - -/* -// specifiedEfficiency = 95; // commented out due to this not making sense - if (std::fabs(eeFLAValue * plMultiplier[4] - specifiedEfficiency) > std::fabs(seFLAValue * plMultiplier[4] - specifiedEfficiency)) - { - // SE is the nominal efficiency - auto const effVal = MotorEfficiency(lineFrequency, motorRPM, Motor::EfficiencyClass::STANDARD, - motorRatedPower).calculate(1, specifiedEfficiency); - estimatedFLA = adjustForVoltage(seFLAValue * plMultiplier[4], effVal); - return { - { - seFLAValue * plMultiplier[0], seFLAValue * plMultiplier[1], seFLAValue * plMultiplier[2], - seFLAValue * plMultiplier[3], seFLAValue * plMultiplier[4], seFLAValue * plMultiplier[5] - } - }; - } else { - /// EE is the nominal efficiency - auto const effVal = MotorEfficiency(lineFrequency, motorRPM, Motor::EfficiencyClass::ENERGY_EFFICIENT, - motorRatedPower).calculate(1, specifiedEfficiency); - estimatedFLA = adjustForVoltage(eeFLAValue * plMultiplier[4], effVal); - return { - { - eeFLAValue * plMultiplier[0], eeFLAValue * plMultiplier[1], eeFLAValue * plMultiplier[2], - eeFLAValue * plMultiplier[3], eeFLAValue * plMultiplier[4], eeFLAValue * plMultiplier[5] - } - }; - } - } - return {}; -*/ } diff --git a/tests/EstimateFLA.unit.cpp b/tests/EstimateFLA.unit.cpp deleted file mode 100644 index 0d468269..00000000 --- a/tests/EstimateFLA.unit.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "catch.hpp" -#include -//#include -#include -#include - - -TEST_CASE( "Estimate FLA", "[EstimateFLA]" ) { - auto fla1 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460); - auto fla2 = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460); - - std::ofstream fout; - fout.open("debug.txt", std::ios::app); - auto results1 = fla1.calculate(); - auto results2 = fla2.calculate(); - fout << "EstimateFLA.unit.cpp" << std::endl; - fout << "------------------------" << std::endl; - fout << "results1:" << std::endl; - fout << "{"; - for (const double &result : results1) - { - fout << result << ", "; - } - fout << "}"; - fout << std::endl; - fout << "results2:" << std::endl; - fout << "{"; - for (const double &result : results2) - { - fout << result << ", "; - } - fout << "}"; - fout << std::endl; - auto estFLA1 = fla1.getEstimatedFLA(); - auto estFLA2 = fla2.getEstimatedFLA(); - fout << "estFLA1: " << estFLA1 << std::endl; - fout << "estFLA2: " << estFLA2 << std::endl; - fout << "End" << std::endl; - fout << "------------------------" << std::endl; - fout.close(); - - CHECK(estFLA1 == Approx(228.4)); - CHECK(estFLA2 == Approx(227.3)); - //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460).calculate() == Approx(227.3)); - //CHECK(EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460).calculate() == Approx(228.4)); -} \ No newline at end of file diff --git a/tests/Results.unit.cpp b/tests/Results.unit.cpp index ad8857a6..779cb077 100644 --- a/tests/Results.unit.cpp +++ b/tests/Results.unit.cpp @@ -518,17 +518,25 @@ TEST_CASE( "EstimateFLA", "[EstimateFLA]" ) { t = EstimateFLA(100, 900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 80, 220); t.calculate(); - CHECK(t.getEstimatedFLA() == Approx(311.3720600292)); + CHECK(t.getEstimatedFLA() == Approx(312.5479443728)); //311.3720600292 - t = EstimateFLA(120, 1900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 90, 220); + t = EstimateFLA(125, 1900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 90, 220); // 120 -> 125, t.calculate(); - CHECK(t.getEstimatedFLA() == Approx(291.0633925033)); + CHECK(t.getEstimatedFLA() == Approx(302.2156478756)); //291.0633925033 t = EstimateFLA(90, 900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 120); t.calculate(); CHECK(t.getEstimatedFLA() == Approx(432.5925070407)); - t = EstimateFLA(150, 2900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 55, 90); + t = EstimateFLA(150, 2900, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 55, 600); // 90 -> 600 t.calculate(); - CHECK(t.getEstimatedFLA() == Approx(1457.2693184418)); + CHECK(t.getEstimatedFLA() == Approx(218.1935995715)); //1457.2693184418 + + t = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 94, 460); + t.calculate(); + CHECK(t.getEstimatedFLA() == Approx(228.3902237064)); + + t = EstimateFLA(200, 1780, Motor::LineFrequency::FREQ60, Motor::EfficiencyClass::SPECIFIED, 95, 460); + t.calculate(); + CHECK(t.getEstimatedFLA() == Approx(227.288340026)); } From 0437b31836d502551e5dd5648ce7022f3b738991 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 30 Mar 2020 12:13:51 -0400 Subject: [PATCH 189/217] Added 8, 10, 12, 16, 18, 20, 24 pipe to CompressedAir.h --- include/calculator/util/CompressedAir.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/calculator/util/CompressedAir.h b/include/calculator/util/CompressedAir.h index 0a93b021..59a1d4d8 100644 --- a/include/calculator/util/CompressedAir.h +++ b/include/calculator/util/CompressedAir.h @@ -175,7 +175,8 @@ namespace Compressor { oneAndOneFourth(oneAndOneFourth * 0.0104), oneAndOneHalf(oneAndOneHalf * 0.0141), two(two * 0.0233), twoAndOneHalf(twoAndOneHalf * 0.0333), three(three * 0.0513), threeAndOneHalf(threeAndOneHalf * 0.0687), four(four * 0.0884), five(five * 0.1389), - six(six * 0.2006), + six(six * 0.2006), eight(eight * 0.3442), ten(0.5476), twelve(0.7763), fourteen(fourteen * 0.9354), + sixteen(sixteen * 1.223), eighteen(eighteen * 1.555), twenty(twenty * 1.926), twentyFour(twentyFour * 2.793), totalPipeVolume(this->oneHalf + this->threeFourths + this->one + this->oneAndOneFourth + this->oneAndOneHalf + this->two + this->twoAndOneHalf + this->three + this->threeAndOneHalf + this->four + this->five + this->six) @@ -192,11 +193,14 @@ namespace Compressor { oneAndOneFourth(compVel(1.5)), oneAndOneHalf(compVel(2.04)), two(compVel(3.36)), twoAndOneHalf(compVel(4.79)), three(compVel(7.39)), threeAndOneHalf(compVel(9.89)), four(compVel(12.73)), five(compVel(20)), - six(compVel(28.89)) + six(compVel(28.89)), eight(compVel(50.02)), ten(compVel(78.85)), twelve(compVel(111.9)), + fourteen(compVel(135.3)), sixteen(compVel(176.7)), eighteen(compVel(224)), twenty(compVel(278)), + twentyFour(compVel(402.10)) {} const double oneHalf, threeFourths, one, oneAndOneFourth, oneAndOneHalf, two; const double twoAndOneHalf, three, threeAndOneHalf, four, five, six; + const double eight, ten, twelve, fourteen, sixteen, eighteen, twenty, twentyFour; const double totalPipeVolume = 0; }; From fed8d727471c561d88aea7f2bea95ef0773e30b5 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 1 Apr 2020 12:16:55 -0400 Subject: [PATCH 190/217] Updated unit and bindings tests for AirVelocity --- Docker/Dockerfile | 4 ++-- Docker/docker_commands.txt | 2 +- bindings/standalone.h | 8 ++++++++ tests/CompressedAir.unit.cpp | 16 ++++++++++++---- tests/js/standalone.js | 12 ++++++++++-- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Docker/Dockerfile b/Docker/Dockerfile index 5ab0c0cb..4f141069 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -115,8 +115,8 @@ RUN npm install tap@12.6.0 --save-dev WORKDIR /home/ # Install emacs -RUN apt-get -y install emacs -RUN emacs --version +#RUN apt-get -y install emacs +#RUN emacs --version # Install sqlite3 RUN apt-get install sqlite3 libsqlite3-dev diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt index ec923b52..7fe74228 100644 --- a/Docker/docker_commands.txt +++ b/Docker/docker_commands.txt @@ -14,7 +14,7 @@ docker login docker push comma64/ornl:amo-tools-suite PowerShell (remove all images): -docker rmi $(docker images -q) +docker rmi $(docker images -q) --force docker stop $(docker ps -aq) 2>/dev/null || true docker rm $(docker ps -a -q) 2>/dev/null|| true diff --git a/bindings/standalone.h b/bindings/standalone.h index ee72a8c8..19855479 100644 --- a/bindings/standalone.h +++ b/bindings/standalone.h @@ -271,6 +271,14 @@ NAN_METHOD(airVelocity) { SetR("four", output.four); SetR("five", output.five); SetR("six", output.six); + SetR("eight", output.eight); + SetR("ten", output.ten); + SetR("twelve", output.twelve); + SetR("fourteen", output.fourteen); + SetR("sixteen", output.sixteen); + SetR("eighteen", output.eighteen); + SetR("twenty", output.twenty); + SetR("twentyFour", output.twentyFour); info.GetReturnValue().Set(r); } diff --git a/tests/CompressedAir.unit.cpp b/tests/CompressedAir.unit.cpp index 06e7d5ed..41f448b8 100644 --- a/tests/CompressedAir.unit.cpp +++ b/tests/CompressedAir.unit.cpp @@ -122,14 +122,22 @@ TEST_CASE( "Compressor Air Velocity", "[CompressedAir][AirVelocity]") { CHECK(expected.at(5) == Approx(results.two)); CHECK(expected.at(6) == Approx(results.twoAndOneHalf)); CHECK(expected.at(7) == Approx(results.three)); -// CHECK(expected.at(8) == Approx(results.threeAndOneHalf)); + CHECK(expected.at(8) == Approx(results.threeAndOneHalf)); CHECK(expected.at(9) == Approx(results.four)); -// CHECK(expected.at(10) == Approx(results.five)); + CHECK(expected.at(10) == Approx(results.five)); CHECK(expected.at(11) == Approx(results.six)); + CHECK(expected.at(12) == Approx(results.eight)); + CHECK(expected.at(13) == Approx(results.ten)); + CHECK(expected.at(14) == Approx(results.twelve)); + CHECK(expected.at(15) == Approx(results.fourteen)); + CHECK(expected.at(16) == Approx(results.sixteen)); + CHECK(expected.at(17) == Approx(results.eighteen)); + CHECK(expected.at(18) == Approx(results.twenty)); + CHECK(expected.at(19) == Approx(results.twentyFour)); }; - compare(Compressor::AirVelocity(1800, 100, 14.7).calculate(), {1845.5100261552, 1044.628316691, 643.7825672634, 369.102005231, 271.3985332581, 164.7776809, 115.585179, 74.9192162174, 0, 43.4919880476, 0, 19.164174726}); - compare(Compressor::AirVelocity(1300, 80, 14.7).calculate(), {1614.361140443, 913.789324779, 563.149235038, 322.872228, 237.406050, 144.139387539, 101.108213388, 65.53563493, 0, 38.044645886, 0, 16.763874771}); + compare(Compressor::AirVelocity(1800, 100, 14.7).calculate(), {1845.5100261552, 1044.628316691, 643.7825672634, 369.102005231, 271.3985332581, 164.7776809, 115.585179, 74.9192162174, 55.9810928055, 43.4919880476, 27.6826503923, 19.164174726, 11.0686327038, 7.0215980703, 4.9477480594, 4.0920399693, 3.1332937626, 2.4716652136, 1.9915575822, 1.3769037748}); + compare(Compressor::AirVelocity(1300, 80, 14.7).calculate(), {1614.361140443, 913.789324779, 563.149235038, 322.872228, 237.406050, 144.139387539, 101.108213388, 65.53563493, 48.969498699, 38.044645886, 24.2154171067, 16.763874771, 9.6822939251, 6.1421476491, 4.3280459529, 3.5795147238, 2.7408508327, 2.1620908131, 1.7421163386, 1.2044475059}); } TEST_CASE( "Compressor Pipe Sizing", "[CompressedAir][PipeSizing]") { diff --git a/tests/js/standalone.js b/tests/js/standalone.js index d79b6ae2..eae5f6de 100644 --- a/tests/js/standalone.js +++ b/tests/js/standalone.js @@ -179,7 +179,7 @@ test('Air System Capacity', function (t) { }); test('Air Velocity', function (t) { - t.plan(13); + t.plan(21); t.type(bindings.airVelocity, 'function'); var compare = function(results, expected) { @@ -195,13 +195,21 @@ test('Air Velocity', function (t) { t.equal(rnd(results.four), expected[9]); t.equal(rnd(results.five), expected[10]); t.equal(rnd(results.six), expected[11]); + t.equal(rnd(results.eight), expected[12]); + t.equal(rnd(results.ten), expected[13]); + t.equal(rnd(results.twelve), expected[14]); + t.equal(rnd(results.fourteen), expected[15]); + t.equal(rnd(results.sixteen), expected[16]); + t.equal(rnd(results.eighteen), expected[17]); + t.equal(rnd(results.twenty), expected[18]); + t.equal(rnd(results.twentyFour), expected[19]); }; var inp = { airFlow: 1800, pipePressure: 100, atmosphericPressure: 14.7 }; - compare(bindings.airVelocity(inp), [1845.510026, 1044.628317, 643.782567, 369.102005, 271.398533, 164.777681, 115.585179, 74.919216, 55.981093, 43.491988, 27.68265, 19.164175]); + compare(bindings.airVelocity(inp), [1845.510026, 1044.628317, 643.782567, 369.102005, 271.398533, 164.777681, 115.585179, 74.919216, 55.981093, 43.491988, 27.68265, 19.164175, 11.068633, 7.021598, 4.947748, 4.09204, 3.133294, 2.471665, 1.991558, 1.376904]); }); test('Pipe Sizing', function (t) { From 4cc4f6000e69f95f0e9203c592ac411304a739d0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 2 Apr 2020 13:09:57 -0400 Subject: [PATCH 191/217] Renamed BaseGasDensity class attributes --- bindings/fan.h | 34 ++++++------ include/fans/Fan203.h | 124 +++++++++++++++++++++--------------------- tests/js/fanTest.js | 96 ++++++++++++++++---------------- 3 files changed, 127 insertions(+), 127 deletions(-) diff --git a/bindings/fan.h b/bindings/fan.h index 4d5f7bf8..07f24a33 100644 --- a/bindings/fan.h +++ b/bindings/fan.h @@ -438,27 +438,27 @@ NAN_METHOD(fanResultsModified) void SetBaseGasDensityData(Local & obj, const BaseGasDensity & bgd) { - Local po = Nan::New("po").ToLocalChecked(); - Local pIn = Nan::New("pIn").ToLocalChecked(); - Local satW = Nan::New("satW").ToLocalChecked(); - Local satDeg = Nan::New("satDeg").ToLocalChecked(); - Local humW = Nan::New("humW").ToLocalChecked(); - Local specVol = Nan::New("specVol").ToLocalChecked(); + Local gasDensity = Nan::New("gasDensity").ToLocalChecked(); + Local absolutePressure = Nan::New("absolutePressure").ToLocalChecked(); + Local saturatedHumidity = Nan::New("saturatedHumidity").ToLocalChecked(); + Local saturationDegree = Nan::New("saturationDegree").ToLocalChecked(); + Local humidityRatio = Nan::New("humidityRatio").ToLocalChecked(); + Local specificVolume = Nan::New("specificVolume").ToLocalChecked(); Local enthalpy = Nan::New("enthalpy").ToLocalChecked(); Local dewPoint = Nan::New("dewPoint").ToLocalChecked(); - Local rh = Nan::New("rh").ToLocalChecked(); - Local satPress = Nan::New("satPress").ToLocalChecked(); - - Nan::Set(obj, po, Nan::New(bgd.getGasDensity())); - Nan::Set(obj, pIn, Nan::New(bgd.getAbsolutePressureIn())); - Nan::Set(obj, satW, Nan::New(bgd.getSaturatedHumidityRatio())); - Nan::Set(obj, satDeg, Nan::New(bgd.getDegreeOfSaturation())); - Nan::Set(obj, humW, Nan::New(bgd.getHumidityRatio())); - Nan::Set(obj, specVol, Nan::New(bgd.getSpecificVolume())); + Local relativeHumidity = Nan::New("relativeHumidity").ToLocalChecked(); + Local saturationPressure = Nan::New("saturationPressure").ToLocalChecked(); + + Nan::Set(obj, gasDensity, Nan::New(bgd.getGasDensity())); + Nan::Set(obj, absolutePressure, Nan::New(bgd.getAbsolutePressureIn())); + Nan::Set(obj, saturatedHumidity, Nan::New(bgd.getSaturatedHumidityRatio())); + Nan::Set(obj, saturationDegree, Nan::New(bgd.getDegreeOfSaturation())); + Nan::Set(obj, humidityRatio, Nan::New(bgd.getHumidityRatio())); + Nan::Set(obj, specificVolume, Nan::New(bgd.getSpecificVolume())); Nan::Set(obj, enthalpy, Nan::New(bgd.getEnthalpy())); Nan::Set(obj, dewPoint, Nan::New(bgd.getDewPoint())); - Nan::Set(obj, rh, Nan::New(bgd.getRelativeHumidity())); - Nan::Set(obj, satPress, Nan::New(bgd.getSaturationPressure())); + Nan::Set(obj, relativeHumidity, Nan::New(bgd.getRelativeHumidity())); + Nan::Set(obj, saturationPressure, Nan::New(bgd.getSaturationPressure())); } NAN_METHOD(getBaseGasDensityRelativeHumidity) { diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index c7729907..75273fa1 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -67,7 +67,7 @@ class BaseGasDensity // used for method 1 BaseGasDensity(const double dryBulbTemp, const double staticPressure, const double barometricPressure, const double gasDensity, const GasType gasType) - : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), po(gasDensity), gasType(gasType) + : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), gasDensity(gasDensity), gasType(gasType) { } /** @@ -78,16 +78,16 @@ class BaseGasDensity * @param gasType, double, gas, type of gas, unitless * @param inputType const, type of input, unitless * @param specificGravity, double, const, specific gravity, unitless - * @return po double, density of the gas in pounds per sqft, lb/scf - * @return pIn double, Absolute Pressure In in in Hg XXX - * @return satW double, Saturated Humidity Ratio, unitless - * @return satDeg double, Degree of Saturation, unitless - * @return humW double, Humidity Ratio, unitless - * @return specVol double, Specific Volume, ft^3/lb + * @return gasDensity double, density of the gas in pounds per sqft, lb/scf + * @return absolutePressure double, Absolute Pressure In in in Hg XXX + * @return saturatedHumidity double, Saturated Humidity Ratio, unitless + * @return saturationDegree double, Degree of Saturation, unitless + * @return humidityRatio double, Humidity Ratio, unitless + * @return specificVolume double, Specific Volume, ft^3/lb * @return entropy double, Entropy, B/lb * @return dewPoint double, Dewpoint, deg F - * @return rh double, Relative Humidity, % - * @return satPress double, Saturation Pressure, in Hg + * @return relativeHumidity double, Relative Humidity, % + * @return saturationPressure double, Saturation Pressure, in Hg */ // TODO ensure correctness BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, @@ -95,15 +95,15 @@ class BaseGasDensity InputType const inputType, double const specificGravity) : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), g(specificGravity), gasType(gasType) { - satPress = calculateSaturationPressure(tdo); - rh = 0; + saturationPressure = calculateSaturationPressure(tdo); + relativeHumidity = 0; if (inputType == InputType::RelativeHumidity) { - rh = relativeHumidityOrDewPoint / 100; + relativeHumidity = relativeHumidityOrDewPoint / 100; } else if (inputType == InputType::DewPoint) { - rh = calculateSaturationPressure(relativeHumidityOrDewPoint) / satPress; + relativeHumidity = calculateSaturationPressure(relativeHumidityOrDewPoint) / saturationPressure; } else if (inputType == InputType::WetBulbTemp) { @@ -115,16 +115,16 @@ class BaseGasDensity /* std::ofstream fout; fout.open("debug.txt", std::ios::app); - fout << "po: " << po << std::endl; - fout << "pIn: " << pIn << std::endl; - fout << "satW: " << satW << std::endl; - fout << "satDeg: " << satDeg << std::endl; - fout << "humW: " << humW << std::endl; - fout << "specVol: " << specVol << std::endl; + fout << "gasDensity: " << gasDensity << std::endl; + fout << "absolutePressure: " << absolutePressure << std::endl; + fout << "saturatedHumidity: " << saturatedHumidity << std::endl; + fout << "saturationDegree: " << saturationDegree << std::endl; + fout << "humidityRatio: " << humidityRatio << std::endl; + fout << "specificVolume: " << specificVolume << std::endl; fout << "enthalpy: " << enthalpy << std::endl; fout << "dewPoint: " << dewPoint << std::endl; - fout << "rh: " << rh << std::endl; - fout << "satPress: " << satPress << std::endl; + fout << "relativeHumidity: " << relativeHumidity << std::endl; + fout << "saturationPressure: " << saturationPressure << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); */ @@ -137,8 +137,8 @@ class BaseGasDensity { if (inputType != InputType::WetBulbTemp) throw std::runtime_error("The wrong constructor for BaseGasDensity was called - check inputType field"); - satPress = calculateSaturationPressure(tdo); - rh = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); + saturationPressure = calculateSaturationPressure(tdo); + relativeHumidity = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); calculateFanAttributes(inputType); @@ -146,16 +146,16 @@ class BaseGasDensity std::ofstream fout; fout.open("debug.txt", std::ios::app); fout << "Wet Bulb" << std::endl; - fout << "po: " << po << std::endl; - fout << "pIn: " << pIn << std::endl; - fout << "satW: " << satW << std::endl; - fout << "satDeg: " << satDeg << std::endl; - fout << "humW: " << humW << std::endl; - fout << "specVol: " << specVol << std::endl; + fout << "gasDensity: " << gasDensity << std::endl; + fout << "absolutePressure: " << absolutePressure << std::endl; + fout << "saturatedHumidity: " << saturatedHumidity << std::endl; + fout << "saturationDegree: " << saturationDegree << std::endl; + fout << "humidityRatio: " << humidityRatio << std::endl; + fout << "specificVolume: " << specificVolume << std::endl; fout << "enthalpy: " << enthalpy << std::endl; fout << "dewPoint: " << dewPoint << std::endl; - fout << "rh: " << rh << std::endl; - fout << "satPress: " << satPress << std::endl; + fout << "relativeHumidity: " << relativeHumidity << std::endl; + fout << "saturationPressure: " << saturationPressure << std::endl; fout << "------------------------------" << std::endl << std::endl; fout.close(); */ @@ -163,27 +163,27 @@ class BaseGasDensity double getGasDensity() const { - return po; + return gasDensity; } double getAbsolutePressureIn() const { - return pIn; + return absolutePressure; } double getSaturatedHumidityRatio() const { - return satW; + return saturatedHumidity; } double getDegreeOfSaturation() const { - return satDeg; + return saturationDegree; } double getHumidityRatio() const { - return humW; + return humidityRatio; } double getSpecificVolume() const { - return specVol; + return specificVolume; } double getEnthalpy() const { @@ -195,11 +195,11 @@ class BaseGasDensity } double getRelativeHumidity() const { - return rh; + return relativeHumidity; } double getSaturationPressure() const { - return satPress; + return saturationPressure; } private: @@ -207,7 +207,7 @@ class BaseGasDensity * @brief Calculates Saturation Pressure * * @param dryBulbTemp double, temperature of inputted air in °F - * @return satPress double, Saturation Pressure, in Hg + * @return saturationPressure double, Saturation Pressure, in Hg */ double calculateSaturationPressure(double dryBulbTemp) const { @@ -243,7 +243,7 @@ class BaseGasDensity * @param relativeHumidity double, relative humidity as % * @param barometricPressure double, pressure in Hg * @param specificGravity double, specific gravity, unitless - * @return humW double, Humidity Ratio, unitless + * @return humidityRatio double, Humidity Ratio, unitless */ double calculateRatioRH(const double dryBulbTemp, const double relativeHumidity, const double barometricPressure, const double specificGravity) const @@ -287,7 +287,7 @@ class BaseGasDensity return pV / psatDb; } /** - * @brief Calculates numerous fan attributes. Note: This function assumes that the member variables pbo, pso, satPress, and rh already + * @brief Calculates numerous fan attributes. Note: This function assumes that the member variables pbo, pso, saturationPressure, and relativeHumidity already have valid values. * * @param inputType const, type of input, unitless @@ -297,17 +297,17 @@ class BaseGasDensity { double const nMol = 0.62198; - pIn = pbo + (pso / 13.608703); - satW = nMol * satPress / (pIn - satPress); - satDeg = rh / ( 1 + ( 1 - rh) * satW / nMol); - humW = satDeg * satW; - specVol = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humW)) / (28.9645 * pIn * 0.4911541); - po = (1 / specVol) * (1 + humW); - enthalpy = (0.247 * tdo) + (humW * (1061 + 0.444 * tdo)); + absolutePressure = pbo + (pso / 13.608703); + saturatedHumidity = nMol * saturationPressure / (absolutePressure - saturationPressure); + saturationDegree = relativeHumidity / ( 1 + ( 1 - relativeHumidity) * saturatedHumidity / nMol); + humidityRatio = saturationDegree * saturatedHumidity; + specificVolume = (10.731557 * (tdo + 459.67) * (1 + 1.6078 * humidityRatio)) / (28.9645 * absolutePressure * 0.4911541); + gasDensity = (1 / specificVolume) * (1 + humidityRatio); + enthalpy = (0.247 * tdo) + (humidityRatio * (1061 + 0.444 * tdo)); if(inputType != InputType::DewPoint) { - double const alpha = std::log(pIn * 0.4911541 * humW / (nMol + humW)); + double const alpha = std::log(absolutePressure * 0.4911541 * humidityRatio / (nMol + humidityRatio)); if(tdo < 32) { @@ -315,7 +315,7 @@ class BaseGasDensity } else { - dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow((pIn * 0.4911541 * humW / (0.62196 + humW)), 0.1984)); + dewPoint = 100.45 + 33.193 * alpha + 2.319 * alpha * alpha + 0.17074 * alpha * alpha * alpha + 1.2063 * (std::pow((absolutePressure * 0.4911541 * humidityRatio / (0.62196 + humidityRatio)), 0.1984)); } } @@ -330,24 +330,24 @@ class BaseGasDensity // gasDensity, specificGravity /** - * @param po double, GasDensity, density of a gas in pounds per sqft, lb/scf + * @param gasDensity double, GasDensity, density of a gas in pounds per sqft, lb/scf * @param g double, Specific Gravity, unitless */ - double po, g; + double gasDensity, g; const GasType gasType; /** - * @param pIn double, Absolute Pressure In in in Hg XXX - * @param satW double, Saturated Humidity Ratio, unitless - * @param satDeg double, Degree of Saturation, unitless - * @param humW double, Humidity Ratio, unitless - * @param specVol double, Specific Volume, ft^3/lb + * @param absolutePressure double, Absolute Pressure In in in Hg XXX + * @param saturatedHumidity double, Saturated Humidity Ratio, unitless + * @param saturationDegree double, Degree of Saturation, unitless + * @param humidityRatio double, Humidity Ratio, unitless + * @param specificVolume double, Specific Volume, ft^3/lb * @param entropy double, Entropy, B/lb * @param dewPoint double, Dewpoint, deg F - * @param rh double, Relative Humidity, % - * @param satPress double, Saturation Pressure, in Hg + * @param relativeHumidity double, Relative Humidity, % + * @param saturationPressure double, Saturation Pressure, in Hg */ - double pIn, satW, satDeg, humW, specVol, enthalpy, dewPoint, rh, satPress; + double absolutePressure, saturatedHumidity, saturationDegree, humidityRatio, specificVolume, enthalpy, dewPoint, relativeHumidity, saturationPressure; friend class PlaneData; friend class Fan203; @@ -484,7 +484,7 @@ class PlaneData then the desktop is sending the values entered for Plane 3a (the first traverse plane). */ auto const calcDensity = [&bgd](Planar const &plane, const double psx) { - return bgd.po * (bgd.tdo + 460) * (psx + 13.63 * plane.barometricPressure) / ((plane.dryBulbTemperature + 460) * (bgd.pso + 13.63 * bgd.pbo)); + return bgd.gasDensity * (bgd.tdo + 460) * (psx + 13.63 * plane.barometricPressure) / ((plane.dryBulbTemperature + 460) * (bgd.pso + 13.63 * bgd.pbo)); }; flowTraverse.gasDensity = calcDensity(flowTraverse, flowTraverse.staticPressure); diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index 2a871fa5..3d364f4a 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -183,16 +183,16 @@ test('getBaseGasDensity', function (t) { var res = bindings.getBaseGasDensityRelativeHumidity(inp); //t.equal(rnd(res), rnd(0.06231117736966)); - t.equal(rnd(res.po), rnd(0.056378)); - t.equal(rnd(res.pIn), rnd(25.27671)); - t.equal(rnd(res.satW), rnd(0.108308)); - t.equal(rnd(res.satDeg), rnd(0.314413)); - t.equal(rnd(res.humW), rnd(0.034053)); - t.equal(rnd(res.specVol), rnd(18.341334)); + t.equal(rnd(res.gasDensity), rnd(0.056378)); + t.equal(rnd(res.absolutePressure), rnd(25.27671)); + t.equal(rnd(res.saturatedHumidity), rnd(0.108308)); + t.equal(rnd(res.saturationDegree), rnd(0.314413)); + t.equal(rnd(res.humidityRatio), rnd(0.034053)); + t.equal(rnd(res.specificVolume), rnd(18.341334)); t.equal(rnd(res.enthalpy), rnd(68.371246)); t.equal(rnd(res.dewPoint), rnd(87.403871)); - t.equal(rnd(res.rh), rnd(0.35)); - t.equal(rnd(res.satPress), rnd(3.748742)); + t.equal(rnd(res.relativeHumidity), rnd(0.35)); + t.equal(rnd(res.saturationPressure), rnd(3.748742)); inp = { dryBulbTemp: 70, @@ -206,16 +206,16 @@ test('getBaseGasDensity', function (t) { }; res = bindings.getBaseGasDensityRelativeHumidity(inp); - t.equal(rnd(res.po), rnd(0.0793577)); - t.equal(rnd(res.pIn), rnd(31.876101)); - t.equal(rnd(res.satW), rnd(0.0147754)); - t.equal(rnd(res.satDeg), rnd(0.594352)); - t.equal(rnd(res.humW), rnd(0.00878179)); - t.equal(rnd(res.specVol), rnd(12.711833)); + t.equal(rnd(res.gasDensity), rnd(0.0793577)); + t.equal(rnd(res.absolutePressure), rnd(31.876101)); + t.equal(rnd(res.saturatedHumidity), rnd(0.0147754)); + t.equal(rnd(res.saturationDegree), rnd(0.594352)); + t.equal(rnd(res.humidityRatio), rnd(0.00878179)); + t.equal(rnd(res.specificVolume), rnd(12.711833)); t.equal(rnd(res.enthalpy), rnd(26.880417)); t.equal(rnd(res.dewPoint), rnd(55.553919)); - t.equal(rnd(res.rh), rnd(0.60)); - t.equal(rnd(res.satPress), rnd(0.739659)); + t.equal(rnd(res.relativeHumidity), rnd(0.60)); + t.equal(rnd(res.saturationPressure), rnd(0.739659)); inp = { dryBulbTemp: 123, @@ -230,16 +230,16 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityDewPoint(inp); //t.equal(rnd(res), rnd(0.06551801779516826)); - t.equal(rnd(res.po), rnd(0.057474)); - t.equal(rnd(res.pIn), rnd(25.27671)); - t.equal(rnd(res.satW), rnd(0.108308)); - t.equal(rnd(res.satDeg), rnd(0.00873)); - t.equal(rnd(res.humW), rnd(0.000946)); - t.equal(rnd(res.specVol), rnd(17.415694)); + t.equal(rnd(res.gasDensity), rnd(0.057474)); + t.equal(rnd(res.absolutePressure), rnd(25.27671)); + t.equal(rnd(res.saturatedHumidity), rnd(0.108308)); + t.equal(rnd(res.saturationDegree), rnd(0.00873)); + t.equal(rnd(res.humidityRatio), rnd(0.000946)); + t.equal(rnd(res.specificVolume), rnd(17.415694)); t.equal(rnd(res.enthalpy), rnd(31.435888)); t.equal(rnd(res.dewPoint), rnd(0.35)); - t.equal(rnd(res.rh), rnd(0.010235)); - t.equal(rnd(res.satPress), rnd(3.748742)); + t.equal(rnd(res.relativeHumidity), rnd(0.010235)); + t.equal(rnd(res.saturationPressure), rnd(3.748742)); inp = { dryBulbTemp: 70, @@ -253,16 +253,16 @@ test('getBaseGasDensity', function (t) { }; res = bindings.getBaseGasDensityDewPoint(inp); - t.equal(rnd(res.po), rnd(0.0793576)); - t.equal(rnd(res.pIn), rnd(31.876101)); - t.equal(rnd(res.satW), rnd(0.0147754)); - t.equal(rnd(res.satDeg), rnd(0.594529)); - t.equal(rnd(res.humW), rnd(0.00878439)); - t.equal(rnd(res.specVol), rnd(12.711886)); + t.equal(rnd(res.gasDensity), rnd(0.0793576)); + t.equal(rnd(res.absolutePressure), rnd(31.876101)); + t.equal(rnd(res.saturatedHumidity), rnd(0.0147754)); + t.equal(rnd(res.saturationDegree), rnd(0.594529)); + t.equal(rnd(res.humidityRatio), rnd(0.00878439)); + t.equal(rnd(res.specificVolume), rnd(12.711886)); t.equal(rnd(res.enthalpy), rnd(26.883261)); t.equal(rnd(res.dewPoint), rnd(55.5)); - t.equal(rnd(res.rh), rnd(0.600175)); - t.equal(rnd(res.satPress), rnd(0.739659)); + t.equal(rnd(res.relativeHumidity), rnd(0.600175)); + t.equal(rnd(res.saturationPressure), rnd(0.739659)); inp = { dryBulbTemp: 123, @@ -278,16 +278,16 @@ test('getBaseGasDensity', function (t) { res = bindings.getBaseGasDensityWetBulb(inp); //t.equal(rnd(res), rnd(0.065456)); - t.equal(rnd(res.po), rnd(0.055653)); - t.equal(rnd(res.pIn), rnd(25.27671)); - t.equal(rnd(res.satW), rnd(0.108308)); - t.equal(rnd(res.satDeg), rnd(0.535317)); - t.equal(rnd(res.humW), rnd(0.057979)); - t.equal(rnd(res.specVol), rnd(19.010256)); + t.equal(rnd(res.gasDensity), rnd(0.055653)); + t.equal(rnd(res.absolutePressure), rnd(25.27671)); + t.equal(rnd(res.saturatedHumidity), rnd(0.108308)); + t.equal(rnd(res.saturationDegree), rnd(0.535317)); + t.equal(rnd(res.humidityRatio), rnd(0.057979)); + t.equal(rnd(res.specificVolume), rnd(19.010256)); t.equal(rnd(res.enthalpy), rnd(95.062901)); t.equal(rnd(res.dewPoint), rnd(103.567304)); - t.equal(rnd(res.rh), rnd(0.574939)); - t.equal(rnd(res.satPress), rnd(3.748742)); + t.equal(rnd(res.relativeHumidity), rnd(0.574939)); + t.equal(rnd(res.saturationPressure), rnd(3.748742)); inp = { dryBulbTemp: 70, @@ -302,16 +302,16 @@ test('getBaseGasDensity', function (t) { }; res = bindings.getBaseGasDensityWetBulb(inp); - t.equal(rnd(res.po), rnd(0.0793575)); - t.equal(rnd(res.pIn), rnd(31.876101)); - t.equal(rnd(res.satW), rnd(0.0147754)); - t.equal(rnd(res.satDeg), rnd(0.594626)); - t.equal(rnd(res.humW), rnd(0.00878583)); - t.equal(rnd(res.specVol), rnd(12.711914)); + t.equal(rnd(res.gasDensity), rnd(0.0793575)); + t.equal(rnd(res.absolutePressure), rnd(31.876101)); + t.equal(rnd(res.saturatedHumidity), rnd(0.0147754)); + t.equal(rnd(res.saturationDegree), rnd(0.594626)); + t.equal(rnd(res.humidityRatio), rnd(0.00878583)); + t.equal(rnd(res.specificVolume), rnd(12.711914)); t.equal(rnd(res.enthalpy), rnd(26.884828)); t.equal(rnd(res.dewPoint), rnd(55.566384)); - t.equal(rnd(res.rh), rnd(0.600272)); - t.equal(rnd(res.satPress), rnd(0.739659)); + t.equal(rnd(res.relativeHumidity), rnd(0.600272)); + t.equal(rnd(res.saturationPressure), rnd(0.739659)); }); From c4e28c5906c66a979db322344b1623fe96b44db7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 27 Apr 2020 21:51:35 -0400 Subject: [PATCH 192/217] Updated Air Leak System Capacity (additional pipe sizes) --- bindings/standalone.h | 19 ++++++++++++++++++- include/calculator/util/CompressedAir.h | 10 +++++++--- tests/CompressedAir.unit.cpp | 6 +++--- tests/js/standalone.js | 3 ++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/bindings/standalone.h b/bindings/standalone.h index 19855479..49eb3f57 100644 --- a/bindings/standalone.h +++ b/bindings/standalone.h @@ -213,13 +213,22 @@ NAN_METHOD(airSystemCapacity) { const double four = Get("four"); const double five = Get("five"); const double six = Get("six"); + const double eight = Get("eight"); + const double ten = Get("ten"); + const double twelve = Get("twelve"); + const double fourteen = Get("fourteen"); + const double sixteen = Get("sixteen"); + const double eighteen = Get("eighteen"); + const double twenty = Get("twenty"); + const double twentyFour = Get("twentyFour"); Compressor::AirSystemCapacity::Output output = Compressor::AirSystemCapacity ( { oneHalf, threeFourths, one, oneAndOneFourth, oneAndOneHalf, two, twoAndOneHalf, three, - threeAndOneHalf, four, five, six + threeAndOneHalf, four, five, six, eight, ten, twelve, fourteen, + sixteen, eighteen, twenty, twentyFour }, std::move(receiverCapacitiesGallons) ).calculate(); @@ -246,6 +255,14 @@ NAN_METHOD(airSystemCapacity) { SetR("four", output.pipeLengths.four); SetR("five", output.pipeLengths.five); SetR("six", output.pipeLengths.six); + SetR("eight", output.pipeLengths.eight); + SetR("ten", output.pipeLengths.ten); + SetR("twelve", output.pipeLengths.twelve); + SetR("fourteen", output.pipeLengths.fourteen); + SetR("sixteen", output.pipeLengths.sixteen); + SetR("eighteen", output.pipeLengths.eighteen); + SetR("twenty", output.pipeLengths.twenty); + SetR("twentyFour", output.pipeLengths.twentyFour); info.GetReturnValue().Set(r); } diff --git a/include/calculator/util/CompressedAir.h b/include/calculator/util/CompressedAir.h index 59a1d4d8..43143e41 100644 --- a/include/calculator/util/CompressedAir.h +++ b/include/calculator/util/CompressedAir.h @@ -170,16 +170,20 @@ namespace Compressor { */ PipeData(const double oneHalf, const double threeFourths, const double one, const double oneAndOneFourth, const double oneAndOneHalf, const double two, const double twoAndOneHalf, const double three, - const double threeAndOneHalf, const double four, const double five, const double six) + const double threeAndOneHalf, const double four, const double five, const double six, const double eight, + const double ten, const double twelve, const double fourteen, const double sixteen, const double eighteen, + const double twenty, const double twentyFour) : oneHalf(oneHalf * 0.0021), threeFourths(threeFourths * 0.0037), one(one * 0.006), oneAndOneFourth(oneAndOneFourth * 0.0104), oneAndOneHalf(oneAndOneHalf * 0.0141), two(two * 0.0233), twoAndOneHalf(twoAndOneHalf * 0.0333), three(three * 0.0513), threeAndOneHalf(threeAndOneHalf * 0.0687), four(four * 0.0884), five(five * 0.1389), - six(six * 0.2006), eight(eight * 0.3442), ten(0.5476), twelve(0.7763), fourteen(fourteen * 0.9354), + six(six * 0.2006), eight(eight * 0.3442), ten(ten * 0.5476), twelve(twelve * 0.7763), fourteen(fourteen * 0.9354), // **ten and twelve** sixteen(sixteen * 1.223), eighteen(eighteen * 1.555), twenty(twenty * 1.926), twentyFour(twentyFour * 2.793), totalPipeVolume(this->oneHalf + this->threeFourths + this->one + this->oneAndOneFourth + this->oneAndOneHalf + this->two + this->twoAndOneHalf + this->three - + this->threeAndOneHalf + this->four + this->five + this->six) + + this->threeAndOneHalf + this->four + this->five + this->six + + this->eight + this->ten + this->twelve + this->fourteen + this->sixteen + + this->eighteen + this->twenty + this->twentyFour) {} /** diff --git a/tests/CompressedAir.unit.cpp b/tests/CompressedAir.unit.cpp index 41f448b8..c4598d1c 100644 --- a/tests/CompressedAir.unit.cpp +++ b/tests/CompressedAir.unit.cpp @@ -88,17 +88,17 @@ TEST_CASE( "Compressor Operating Cost", "[CompressedAir][OperatingCost]") { TEST_CASE( "Compressor Air System Capacity", "[CompressedAir][AirSystemCapacity]") { - auto output = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 0, 300, 0, 1000, 0, 0}, {400, 500, 660, 1060}).calculate(); + auto output = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 0, 300, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {400, 500, 660, 1060}).calculate(); CHECK(output.totalPipeVolume == Approx(138.63)); CHECK(output.totalReceiverVol == Approx(350.2673796791)); CHECK(output.totalCapacityOfCompressedAirSystem == Approx(488.897379679)); - auto output2 = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 500, 300, 0, 1000, 0, 0}, {400, 500, 660, 1060}).calculate(); + auto output2 = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 500, 300, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {400, 500, 660, 1060}).calculate(); CHECK(output2.totalPipeVolume == Approx(155.28)); CHECK(output2.totalReceiverVol == Approx(350.2673796791)); CHECK(output2.totalCapacityOfCompressedAirSystem == Approx(505.5473796791)); - auto output3 = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 500, 300, 0, 1000, 0, 0}, {600, 1500, 660, 1060}).calculate(); + auto output3 = Compressor::AirSystemCapacity({3000, 2000, 1000, 200, 100, 500, 500, 300, 0, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {600, 1500, 660, 1060}).calculate(); CHECK(output3.totalPipeVolume == Approx(155.28)); CHECK(output3.totalReceiverVol == Approx(510.6951871658)); CHECK(output3.totalCapacityOfCompressedAirSystem == Approx(665.9751871658)); diff --git a/tests/js/standalone.js b/tests/js/standalone.js index eae5f6de..f4074b8a 100644 --- a/tests/js/standalone.js +++ b/tests/js/standalone.js @@ -165,7 +165,8 @@ test('Air System Capacity', function (t) { var inp = { oneHalf: 3000, threeFourths: 2000, one: 1000, oneAndOneFourth: 200, oneAndOneHalf: 100, two: 500, twoAndOneHalf: 500, three: 300, - threeAndOneHalf: 0, four: 1000, five: 0, six: 0, + threeAndOneHalf: 0, four: 1000, five: 0, six: 0, eight: 0, ten: 0, twelve: 0, fourteen: 0, sixteen: 0, eighteen: 0, twenty: 0, + twentyFour: 0, receiverCapacities: [ 400, 500, 660, 1060 ] From b847fe01ad9fddd925034d75ab05c52bce094e7b Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 28 Apr 2020 09:33:06 -0400 Subject: [PATCH 193/217] Updated C++ and JS tests for AirSystemCapacity --- tests/CompressedAir.unit.cpp | 17 +++++++++++++++++ tests/js/standalone.js | 12 ++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/CompressedAir.unit.cpp b/tests/CompressedAir.unit.cpp index c4598d1c..8e318f08 100644 --- a/tests/CompressedAir.unit.cpp +++ b/tests/CompressedAir.unit.cpp @@ -102,10 +102,27 @@ TEST_CASE( "Compressor Air System Capacity", "[CompressedAir][AirSystemCapacity] CHECK(output3.totalPipeVolume == Approx(155.28)); CHECK(output3.totalReceiverVol == Approx(510.6951871658)); CHECK(output3.totalCapacityOfCompressedAirSystem == Approx(665.9751871658)); + CHECK(output3.pipeLengths.oneHalf == Approx(6.3)); CHECK(output3.pipeLengths.threeFourths == Approx(7.4)); + CHECK(output3.pipeLengths.one == Approx(6)); + CHECK(output3.pipeLengths.oneAndOneFourth == Approx(2.08)); + CHECK(output3.pipeLengths.oneAndOneHalf == Approx(1.41)); CHECK(output3.pipeLengths.two == Approx(11.65)); + CHECK(output3.pipeLengths.twoAndOneHalf == Approx(16.65)); + CHECK(output3.pipeLengths.three == Approx(15.39)); + CHECK(output3.pipeLengths.threeAndOneHalf == Approx(0)); CHECK(output3.pipeLengths.four == Approx(88.4)); + CHECK(output3.pipeLengths.five == Approx(0)); + CHECK(output3.pipeLengths.six == Approx(0)); + CHECK(output3.pipeLengths.eight == Approx(0)); + CHECK(output3.pipeLengths.ten == Approx(0)); + CHECK(output3.pipeLengths.twelve == Approx(0)); + CHECK(output3.pipeLengths.fourteen == Approx(0)); + CHECK(output3.pipeLengths.sixteen == Approx(0)); + CHECK(output3.pipeLengths.eighteen == Approx(0)); + CHECK(output3.pipeLengths.twenty == Approx(0)); + CHECK(output3.pipeLengths.twentyFour == Approx(0)); CHECK(output3.receiverCapacities.at(0) == Approx(80.2139037433)); CHECK(output3.receiverCapacities.at(1) == Approx(200.5347593583)); CHECK(output3.receiverCapacities.at(3) == Approx(141.7112299465)); diff --git a/tests/js/standalone.js b/tests/js/standalone.js index f4074b8a..aba727f4 100644 --- a/tests/js/standalone.js +++ b/tests/js/standalone.js @@ -141,7 +141,7 @@ test('Operating Cost', function (t) { }); test('Air System Capacity', function (t) { - t.plan(20); + t.plan(28); t.type(bindings.airSystemCapacity, 'function'); var compare = function(results, expected, gallons) { @@ -157,6 +157,14 @@ test('Air System Capacity', function (t) { t.equal(rnd(results.four), expected[9]); t.equal(rnd(results.five), expected[10]); t.equal(rnd(results.six), expected[11]); + t.equal(rnd(results.eight), expected[12]); + t.equal(rnd(results.ten), expected[13]); + t.equal(rnd(results.twelve), expected[14]); + t.equal(rnd(results.fourteen), expected[15]); + t.equal(rnd(results.sixteen), expected[16]); + t.equal(rnd(results.eighteen), expected[17]); + t.equal(rnd(results.twenty), expected[18]); + t.equal(rnd(results.twentyFour), expected[19]); for (var i = 0; i < gallons.length; i++) { t.equal(rnd(results.receiverCapacities[i]), gallons[i]); @@ -176,7 +184,7 @@ test('Air System Capacity', function (t) { t.equal(rnd(results.totalPipeVolume), 155.28); t.equal(rnd(results.totalReceiverVolume), 350.26738); t.equal(rnd(results.totalCapacityOfCompressedAirSystem), 505.54738); - compare(results, [6.3, 7.4, 6, 2.08, 1.41, 11.65, 16.65, 15.39, 0, 88.4, 0, 0], [53.475936, 66.84492, 88.235294, 141.71123]); + compare(results, [6.3, 7.4, 6, 2.08, 1.41, 11.65, 16.65, 15.39, 0, 88.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [53.475936, 66.84492, 88.235294, 141.71123]); }); test('Air Velocity', function (t) { From 5bfe9b500413709d888154f85a8059b7ccd39d75 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 30 Apr 2020 13:59:04 -0400 Subject: [PATCH 194/217] Started work on Air Leak Survey calculator --- bindings/standalone.cpp | 10 +++ bindings/standalone.h | 11 +++ include/calculator/util/CompressedAir.h | 92 +++++++++++++++++++++++++ src/calculator/util/CompressedAir.cpp | 33 +++++++++ tests/CompressedAir.unit.cpp | 23 +++++++ 5 files changed, 169 insertions(+) diff --git a/bindings/standalone.cpp b/bindings/standalone.cpp index 6ec6504a..c61ac9d7 100644 --- a/bindings/standalone.cpp +++ b/bindings/standalone.cpp @@ -33,6 +33,16 @@ NAN_MODULE_INIT(InitStandalone) { Nan::Set(target, New("bagMethod").ToLocalChecked(), GetFunction(New(bagMethod)).ToLocalChecked()); + /* + Nan::Set(target, New("estimateMethod").ToLocalChecked(), + GetFunction(New(estimateMethod)).ToLocalChecked()); + + Nan::Set(target, New("decibelMethod").ToLocalChecked(), + GetFunction(New(decibelMethod)).ToLocalChecked()); + + Nan::Set(target, New("orificeMethod").ToLocalChecked(), + GetFunction(New(orificeMethod)).ToLocalChecked()); + */ } NODE_MODULE(standalone, InitStandalone) \ No newline at end of file diff --git a/bindings/standalone.h b/bindings/standalone.h index 49eb3f57..f74938d8 100644 --- a/bindings/standalone.h +++ b/bindings/standalone.h @@ -354,6 +354,17 @@ NAN_METHOD(bagMethod) { info.GetReturnValue().Set(r); } +/* +NAN_METHOD(estimateMethod) { + inp = Nan::To(info[0]).ToLocalChecked(); + r = Nan::New(); + //ReceiverTank::Method method = static_cast(static_cast(Get("method"))); + //std::string const &leakEstimateTypeStr = GetStr("leakEstimateType"); + EstimateMethod::LeakEstimateType leakEstimateType = static_cast(static_cast(Get("leakEstimateType"))); + const double operatingTime = Get("operatingTime"); + +} +*/ #endif //AMO_TOOLS_SUITE_STANDALONE_H diff --git a/include/calculator/util/CompressedAir.h b/include/calculator/util/CompressedAir.h index 43143e41..f7647905 100644 --- a/include/calculator/util/CompressedAir.h +++ b/include/calculator/util/CompressedAir.h @@ -381,6 +381,98 @@ class BagMethod { double operatingTime, bagFillTime, heightOfBag, diameterOfBag, numberOfUnits; }; +// enum class CompressorType ??? +class EstimateMethod { + public: + struct Output { + Output(const double annualConsumption) : annualConsumption(annualConsumption) + {} + + const double annualConsumption; + }; + + /** + * Constructor for EstimateMethod - The estimate method estimates the air loss by using visual and audible clues. + * @param operatingTime double, operating time of the system per year - hours + * @param leakRateEstimate double, estimated leak rate (determined by visual and audible clues) + */ + EstimateMethod(const double operatingTime, const double leakRateEstimate); + + /** + * @return EstimateMethod::Output, annual consumption + */ + Output calculate(); + + private: + double operatingTime, leakRateEstimate; +}; + +class DecibelsMethod { + // +}; + +class OrificeMethod { + public: + struct Output { + Output(const double standardDensity, const double sonicDensity, const double leakVelocity, const double leakRateLBMmin, + const double leakRateScfm, const double leakRateEstimate, const double annualConsumption) + : standardDensity(standardDensity), sonicDensity(sonicDensity), leakVelocity(leakVelocity), + leakRateLBMmin(leakRateLBMmin), leakRateScfm(leakRateScfm), leakRateEstimate(leakRateEstimate), + annualConsumption(annualConsumption) + {} + + const double standardDensity, sonicDensity, leakVelocity, leakRateLBMmin, leakRateScfm, leakRateEstimate, annualConsumption; + }; + + /** + * Constructor for OrificeMethod - The orifice method estimates the air loss by using the pressure and diameter of the orifice + * @param operatingTime double, operating time of the system per year - hours + * @param airTemp double, compressor air temperature (usually between 200 and 300 degrees F) + * @param atmPressure double, atmospheric temperature (standard pressure is 14.7 psia) + * @param dischargeCoef double, discharge coefficient used to capture the effect of the shape of the outlet on air loss + * @param parameter double, diameter of the orifice in inches + * @param supplyPressure double, supply pressure to the orifice in psi + * @param numOrifices int, number of orifices + */ + OrificeMethod(const double operatingTime, const double airTemp, const double atmPressure, const double dischargeCoef, + const double diameter, const double supplyPressure, const int numOrifices); + + /** + * @return OrificeMethod::Output, standard density, sonic density, leak velocity, leak rate LBMmin, leak rate Scfm, leak rate estimate, annual consumption + */ + Output calculate(); + + private: + double operatingTime, airTemp, atmPressure, dischargeCoef, diameter, supplyPressure; + int numOrifices; + +}; + +class AirLeakSurvey { + /** + * enum class for Method Type + * + */ + enum class MethodType + { + EstimateMethod, + DecibelsMethod, + BagMethod, + OrificeMethod + }; + /* + annualOperatingHours: number; + // + // leakDescription + // anualOperatingHours + // measurementMethod + // utilityType = 'electricity' or 'compressed air' + // utilityCost comes from TH setup but is editable input + // compressorControlType + // compressorType + leaks: Array; + */ +}; #endif //AMO_TOOLS_SUITE_COMPRESSEDAIR_H diff --git a/src/calculator/util/CompressedAir.cpp b/src/calculator/util/CompressedAir.cpp index 0bd2be61..408e3148 100644 --- a/src/calculator/util/CompressedAir.cpp +++ b/src/calculator/util/CompressedAir.cpp @@ -1,4 +1,7 @@ #include "calculator/util/CompressedAir.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif PneumaticAirRequirement::PneumaticAirRequirement(const PistonType pistonType, const double cylinderDiameter, const double cylinderStroke, const double pistonRodDiameter, @@ -167,3 +170,33 @@ BagMethod::Output BagMethod::calculate() { auto const flowRate = (0.0273 * std::pow(diameterOfBag, 2) * heightOfBag) / bagFillTime; return {flowRate, (flowRate * operatingTime * numberOfUnits * 60) / 1000 }; } + +EstimateMethod::EstimateMethod(const double operatingTime, const double leakRateEstimate) + : operatingTime(operatingTime), leakRateEstimate(leakRateEstimate) +{} + +EstimateMethod::Output EstimateMethod::calculate() { + //return {flowRate, (flowRate * operatingTime * numberOfUnits * 60) / 1000 }; + //return {(leakRateEstimate * operatingTime * 60) / 1000}; + EstimateMethod::Output output((leakRateEstimate * operatingTime * 60) / 1000); + return output; +} + +OrificeMethod::OrificeMethod(const double operatingTime, const double airTemp, const double atmPressure, const double dischargeCoef, + const double diameter, const double supplyPressure, const int numOrifices) + : operatingTime(operatingTime), airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), + supplyPressure(supplyPressure), numOrifices(numOrifices) +{} + +OrificeMethod::Output OrificeMethod::calculate() { + const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); + const double sonicDensity = std::pow(standardDensity * (2 / (1.4 + 1)), 1/(1.4 - 1)); + const double leakVelocity = std::pow(((2 * 1.4) / (1.4 + 1)) * 53.34 * airTemp * 32.2, 0.5); + const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; + const double leakRateScfm = leakRateLBMmin / standardDensity; + const double leakRateEstimate = leakRateScfm * numOrifices; + const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; + OrificeMethod::Output output(standardDensity, sonicDensity, leakVelocity, leakRateLBMmin, leakRateScfm, leakRateEstimate, annualComsumption); + + return output; +} diff --git a/tests/CompressedAir.unit.cpp b/tests/CompressedAir.unit.cpp index 8e318f08..99c1735a 100644 --- a/tests/CompressedAir.unit.cpp +++ b/tests/CompressedAir.unit.cpp @@ -192,3 +192,26 @@ TEST_CASE( "Bag Method", "[CompressedAir][BagMethod]") { compare(BagMethod(115200 / 60.0, 20, 10, 10, 1).calculate(), BagMethod::Output(1.365, 157.248)); compare(BagMethod(100000 / 60.0, 20, 10, 10, 1).calculate(), BagMethod::Output(1.365, 136.5)); } + +TEST_CASE( "Estimate Method", "[CompressedAir][EstimateMethod]") { + //auto const compare = [](EstimateMethod::Output const & results, EstimateMethod::Output const & expected) { + //CHECK(expected.annualConsumption == Approx(results.annualConsumption)); + //}; + //compare(EstimateMethod(EstimateMethod::LeakEstimateType::Small, 115200 / 60.0).calculate(), EstimateMethod::Output(5.25)); + //compare(EstimateMethod(EstimateMethod::LeakEstimateType::Small, 115200 / 60.0).calculate(), EstimateMethod::Output(1.092)); + CHECK(EstimateMethod(1280, 0.1).calculate().annualConsumption == Approx(EstimateMethod::Output(7.68).annualConsumption)); +} + +TEST_CASE( "Orifice Method", "[CompressedAir][OrificeMethod]") { + auto const compare = [](OrificeMethod::Output const & results, OrificeMethod::Output const & expected) { + CHECK(expected.standardDensity == Approx(results.standardDensity)); + CHECK(expected.sonicDensity == Approx(results.sonicDensity)); + CHECK(expected.leakVelocity == Approx(results.leakVelocity)); + CHECK(expected.leakRateLBMmin == Approx(results.leakRateLBMmin)); + CHECK(expected.leakRateScfm == Approx(results.leakRateScfm)); + CHECK(expected.leakRateEstimate == Approx(results.leakRateEstimate)); + CHECK(expected.annualConsumption == Approx(results.annualConsumption)); + }; + + compare(OrificeMethod(115200 / 60.0, 250.0, 14.7, 1.0, 6.0, 6.2, 4).calculate(), OrificeMethod::Output(0.2256917885, 0.0153403857, 707.7792735027, 127.9131698485, 566.7604066752, 2267.0416267007, 261163.1953959255)); +} From dcce9f0db2f51bd02498b9a4355667419413b34a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 1 May 2020 16:22:54 -0400 Subject: [PATCH 195/217] Added estimate, orifice, and decibel classes and bindings --- bindings/calculator.h | 61 +++++++++++++++ .../calculator/util/CompressedAirReduction.h | 77 ++++++++++++++++++- .../util/CompressedAirReduction.cpp | 64 ++++++++++++++- tests/CompressedAirReduction.unit.cpp | 18 +++++ tests/js/calculator.js | 70 +++++++++++++++++ tests/js/dbBindingsTest.js | 6 +- 6 files changed, 289 insertions(+), 7 deletions(-) diff --git a/bindings/calculator.h b/bindings/calculator.h index 07a95d53..39996884 100644 --- a/bindings/calculator.h +++ b/bindings/calculator.h @@ -517,6 +517,61 @@ CompressedAirOtherMethodData getCompressedAirOtherMethodData(Local obj) return {consumption}; } +OrificeMethodData getOrificeMethodData(Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("orificeMethodData").ToLocalChecked(); + Local orificeMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (orificeMethodDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CompressedAirReduction: getOrificeMethodData method in calculator.h: orificeMethodData not present in object").c_str()); + } + double airTemp = GetDouble("compressorAirTemp", orificeMethodDataV8); + double atmPressure = GetDouble("atmosphericPressure", orificeMethodDataV8); + double dischargeCoef = GetDouble("dischargeCoefficient", orificeMethodDataV8); + double diameter = GetDouble("orificeDiameter", orificeMethodDataV8); + double supplyPressure = GetDouble("supplyPressure", orificeMethodDataV8); + int numOrifices = static_cast(GetDouble("numberOfOrifices", orificeMethodDataV8)); + return { + airTemp, + atmPressure, + dischargeCoef, + diameter, + supplyPressure, + numOrifices}; +} + +DecibelsMethodData getDecibelsMethodData(Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("decibelsMethodData").ToLocalChecked(); + Local decibelsMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (decibelsMethodDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CompressedAirReduction: getDecibelsMethodData method in calculator.h: decibelsMethodData not present in object").c_str()); + } + double leakRateEstimate = GetDouble("soundIntensity", decibelsMethodDataV8); + return { + leakRateEstimate}; +} + +EstimateMethodData getEstimateMethodData(Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("estimateMethodData").ToLocalChecked(); + Local estimateMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (estimateMethodDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CompressedAirReduction: getEstimateMethodData method in calculator.h: estimateMethodData not present in object").c_str()); + } + double leakRateEstimate = GetDouble("leakRateEstimate", estimateMethodDataV8); + return { + leakRateEstimate}; +} + CompressorElectricityData getCompressorElectricityData(Local obj) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); @@ -544,6 +599,9 @@ CompressedAirReductionInput constructCompressedAirReductionInput(Local o BagMethodData bagMethodData = getBagMethodData(obj); PressureMethodData pressureMethodData = getPressureMethodData(obj); CompressedAirOtherMethodData otherMethodData = getCompressedAirOtherMethodData(obj); + OrificeMethodData orificeMethodData = getOrificeMethodData(obj); + DecibelsMethodData decibelsMethodData = getDecibelsMethodData(obj); + EstimateMethodData estimateMethodData = getEstimateMethodData(obj); CompressorElectricityData electricityData = getCompressorElectricityData(obj); int units = static_cast(GetDouble("units", obj)); return { @@ -555,6 +613,9 @@ CompressedAirReductionInput constructCompressedAirReductionInput(Local o bagMethodData, pressureMethodData, otherMethodData, + orificeMethodData, + decibelsMethodData, + estimateMethodData, electricityData, units}; } diff --git a/include/calculator/util/CompressedAirReduction.h b/include/calculator/util/CompressedAirReduction.h index aaceb057..c6f502ee 100644 --- a/include/calculator/util/CompressedAirReduction.h +++ b/include/calculator/util/CompressedAirReduction.h @@ -55,6 +55,68 @@ class PressureMethodData double supplyPressure; }; +class DecibelsMethodData +{ + public: + DecibelsMethodData(const double soundIntensity) : soundIntensity(soundIntensity) {} + + double calculate(); + + private: + double soundIntensity; + double linePressure; + double decibels; + double decibelRatingA; // y1 + double presureA; // x1 + double firstFlowA; // q11 + double secondFlowA; // q22 + double decibelRatingB; + double presureB; + double firstFlowB; + double secondFlowB; +}; + +class EstimateMethodData +{ + public: + EstimateMethodData(const double leakRateEstimate) : leakRateEstimate(leakRateEstimate) {} + + double getLeakRateEstimate() const {return leakRateEstimate; } + void setLeakRateEstimate(double leakRateEstimate); + + private: + double leakRateEstimate; +}; + +class OrificeMethodData +{ + public: + OrificeMethodData(const double airTemp, const double atmPressure, const double dischargeCoef, // removed operatingTime + const double diameter, const double supplyPressure, const int numOrifices) + : airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), + supplyPressure(supplyPressure), numOrifices(numOrifices) {} + + double getAirTemp() const { return airTemp; } + double getAtmPressure() const { return atmPressure; } + double getDischargeCoef() const { return dischargeCoef; } + double getDiameter() const { return diameter; } + double getSupplyPressure() const { return supplyPressure; } + int getNumOrifices() const { return numOrifices; } + + void setAirTemp(double airTemp); + void setAtmPressure(double atmPressure); + void setDischargeCoef(double dischargeCoef); + void setDiameter(double diameter); + void setSupplyPressure(double supplyPressure); + void setNumOrifices(int numOrifices); + + double calculate(); + + private: + double airTemp, atmPressure, dischargeCoef, diameter, supplyPressure; + int numOrifices; +}; + class CompressedAirOtherMethodData { public: @@ -87,13 +149,16 @@ class CompressedAirReductionInput CompressedAirReductionInput(const int hoursPerYear, const int utilityType, const double utilityCost, const int measurementMethod, const CompressedAirFlowMeterMethodData flowMeterMethodData, const BagMethodData bagMethodData, const PressureMethodData pressureMethodData, const CompressedAirOtherMethodData otherMethodData, - const CompressorElectricityData compressorElectricityData, const int units) + const OrificeMethodData orificeMethodData, const DecibelsMethodData decibelsMethodData, + const EstimateMethodData estimateMethodData, const CompressorElectricityData compressorElectricityData, + const int units) : hoursPerYear(hoursPerYear), utilityType(utilityType), utilityCost(utilityCost), measurementMethod(measurementMethod), flowMeterMethodData(flowMeterMethodData), bagMethodData(bagMethodData), - pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), + pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), orificeMethodData(orificeMethodData), + decibelsMethodData(decibelsMethodData), estimateMethodData(estimateMethodData), compressorElectricityData(compressorElectricityData), units(units) {} - int getHoursPerYear() const { return hoursPerYear; } + int getHoursPerYear() const { return hoursPerYear; } // operating time int getUtilityType() const { return utilityType; } int getMeasurementMethod() const { return measurementMethod; } int getUnits() const { return units; } @@ -102,6 +167,9 @@ class CompressedAirReductionInput BagMethodData getBagMethodData() const { return bagMethodData; } PressureMethodData getPressureMethodData() const { return pressureMethodData; } CompressedAirOtherMethodData getOtherMethodData() const { return otherMethodData; } + OrificeMethodData getOrificeMethodData() const { return orificeMethodData; } + DecibelsMethodData getDecibelsMethodData() const { return decibelsMethodData; } + EstimateMethodData getEstimateMethodData() const { return estimateMethodData; } CompressorElectricityData getCompressorElectricityData() const { return compressorElectricityData; } private: @@ -112,6 +180,9 @@ class CompressedAirReductionInput BagMethodData bagMethodData; PressureMethodData pressureMethodData; CompressedAirOtherMethodData otherMethodData; + OrificeMethodData orificeMethodData; + DecibelsMethodData decibelsMethodData; + EstimateMethodData estimateMethodData; CompressorElectricityData compressorElectricityData; int units; }; diff --git a/src/calculator/util/CompressedAirReduction.cpp b/src/calculator/util/CompressedAirReduction.cpp index e0d1a3d7..ab7b44ed 100644 --- a/src/calculator/util/CompressedAirReduction.cpp +++ b/src/calculator/util/CompressedAirReduction.cpp @@ -27,7 +27,7 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); } - // orifice/pressure method + // pressure method else if (compressedAirReductionInput.getMeasurementMethod() == 2) { PressureMethodData pressureMethodData = compressedAirReductionInput.getPressureMethodData(); @@ -41,6 +41,25 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() CompressedAirOtherMethodData otherMethodData = compressedAirReductionInput.getOtherMethodData(); tmpTotalConsumption = otherMethodData.getConsumption(); } + // orifice method + else if(compressedAirReductionInput.getMeasurementMethod() == 4) + { + OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); + tmpFlowRate = orificeMethodData.calculate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) / 1000; // / 1000? + } + // decibels method + else if(compressedAirReductionInput.getMeasurementMethod() == 5) + { + DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); + } + // estimate method + else if(compressedAirReductionInput.getMeasurementMethod() == 6) + { + EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); + tmpFlowRate = estimateMethodData.getLeakRateEstimate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) / 1000; // / 1000? + } //electricity calculation if (compressedAirReductionInput.getUtilityType() == 0) @@ -89,6 +108,19 @@ double PressureMethodData::calculate() return singleNozzleFlowRate; } +double OrificeMethodData::calculate() +{ + const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); + const double sonicDensity = std::pow(standardDensity * (2 / (1.4 + 1)), 1/(1.4 - 1)); + const double leakVelocity = std::pow(((2 * 1.4) / (1.4 + 1)) * 53.34 * airTemp * 32.2, 0.5); + const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; + const double leakRateScfm = leakRateLBMmin / standardDensity; + const double leakRateEstimate = leakRateScfm * numOrifices; + //const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; + + return leakRateEstimate; +} + double CompressorElectricityData::calculate() { const double c = 1.0 / 60; @@ -135,6 +167,36 @@ void BagMethodData::setFillTime(const double fillTime) this->fillTime = fillTime; } +void OrificeMethodData::setAirTemp(const double airTemp) +{ + this->airTemp = airTemp; +} +void OrificeMethodData::setAtmPressure(const double atmPressure) +{ + this->atmPressure = atmPressure; +} +void OrificeMethodData::setDischargeCoef(const double dischargeCoef) +{ + this->dischargeCoef = dischargeCoef; +} +void OrificeMethodData::setDiameter(const double diameter) +{ + this->diameter = diameter; +} +void OrificeMethodData::setSupplyPressure(const double supplyPressure) +{ + this->supplyPressure = supplyPressure; +} +void OrificeMethodData::setNumOrifices(const int numOrifices) +{ + this->numOrifices = numOrifices; +} + +void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) +{ + this->leakRateEstimate = leakRateEstimate; +} + void CompressedAirFlowMeterMethodData::setMeterReading(const double meterReading) { this->meterReading = meterReading; diff --git a/tests/CompressedAirReduction.unit.cpp b/tests/CompressedAirReduction.unit.cpp index ef8e448e..c7382788 100644 --- a/tests/CompressedAirReduction.unit.cpp +++ b/tests/CompressedAirReduction.unit.cpp @@ -9,6 +9,9 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method", "[CompressedAirReduction BagMethodData(10, 5, 30), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(1.428, 1.38233), 1)}; @@ -29,6 +32,9 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method and Electricity", "[Compre BagMethodData(10, 5, 30), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(0.8, 0.16), 1)}; @@ -49,6 +55,9 @@ TEST_CASE("Compressed Air Reduction Bag Method and Electricity", "[CompressedAir BagMethodData(15, 10, 12), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 2)}; @@ -69,6 +78,9 @@ TEST_CASE("Compressed Air Reduction Orifice Pressure Method and Electricity", "[ BagMethodData(15, 10, 12), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; @@ -89,6 +101,9 @@ TEST_CASE("Compressed Air Reduction Orifice Pressure Method Multiple Nozzles", " BagMethodData(15, 10, 12), PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 3)}; @@ -109,6 +124,9 @@ TEST_CASE("Compressed Air Reduction Other Method", "[CompressedAirReduction][Uti BagMethodData(15, 10, 12), PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(1.0), + EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 381897c3..78f84703 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -264,6 +264,20 @@ test('Compressed Air Reduction Basic Test', function (t) { otherMethodData: { consumption: 200000 }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 1 + }, + decibelsMethodData: { + soundIntensity: 0 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -314,6 +328,20 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 1 + }, + decibelsMethodData: { + soundIntensity: 0 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -347,6 +375,20 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 1 + }, + decibelsMethodData: { + soundIntensity: 0 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -378,6 +420,20 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 1 + }, + decibelsMethodData: { + soundIntensity: 0 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -409,6 +465,20 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 1 + }, + decibelsMethodData: { + soundIntensity: 0 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 diff --git a/tests/js/dbBindingsTest.js b/tests/js/dbBindingsTest.js index ace9e93e..0d7c5cd2 100644 --- a/tests/js/dbBindingsTest.js +++ b/tests/js/dbBindingsTest.js @@ -699,7 +699,7 @@ test('dbSelectPumpData', function (t) { t.equal(res.speed, obj.speed, res.speed + " != " + obj.speed); t.equal(res.numStages, obj.numStages, res.numStages + " != " + obj.numStages); t.equal(res.yearlyOperatingHours, obj.yearlyOperatingHours, res.yearlyOperatingHours + " != " + obj.yearlyOperatingHours); - t.equal(res.yearlyInstalled, obj.yearlyInstalled, res.yearlyInstalled + " != " + obj.yearlyInstalled); + t.equal(res.yearInstalled, obj.yearInstalled, res.yearInstalled + " != " + obj.yearInstalled); t.equal(res.finalMotorRpm, obj.finalMotorRpm, res.finalMotorRpm + " != " + obj.finalMotorRpm); t.equal(res.inletDiameter, obj.inletDiameter, res.inletDiameter + " != " + obj.inletDiameter); t.equal(res.weight, obj.weight, res.weight + " != " + obj.weight); @@ -828,7 +828,7 @@ test('dbInsertPump', function (t) { t.equal(res[size].speed, obj.speed, res[size].speed + " != " + obj.speed); t.equal(res[size].numStages, obj.numStages, res[size].numStages + " != " + obj.numStages); t.equal(res[size].yearlyOperatingHours, obj.yearlyOperatingHours, res[size].yearlyOperatingHours + " != " + obj.yearlyOperatingHours); - t.equal(res[size].yearlyInstalled, obj.yearlyInstalled, res[size].yearlyInstalled + " != " + obj.yearlyInstalled); + t.equal(res[size].yearInstalled, obj.yearInstalled, res[size].yearInstalled + " != " + obj.yearInstalled); t.equal(res[size].finalMotorRpm, obj.finalMotorRpm, res[size].finalMotorRpm + " != " + obj.finalMotorRpm); t.equal(res[size].inletDiameter, obj.inletDiameter, res[size].inletDiameter + " != " + obj.inletDiameter); t.equal(res[size].weight, obj.weight, res[size].weight + " != " + obj.weight); @@ -851,7 +851,7 @@ test('dbInsertPump', function (t) { t.equal(res[size].shaftDiameter, obj.shaftDiameter, res[size].shaftDiameter + " != " + obj.shaftDiameter); t.equal(res[size].impellerDiameter, obj.impellerDiameter, res[size].impellerDiameter + " != " + obj.impellerDiameter); t.equal(res[size].efficiency, obj.efficiency, res[size].efficiency + " != " + obj.efficiency); - t.equal(res[size].output6sizeHz, obj.output6sizeHz, res[size].output6sizeHz + " != " + obj.output6sizeHz); + t.equal(res[size].output60Hz, obj.output60Hz, res[size].output60Hz + " != " + obj.output60Hz); t.equal(res[size].minFlowSize, obj.minFlowSize, res[size].minFlowSize + " != " + obj.minFlowSize); t.equal(res[size].pumpSize, obj.pumpSize, res[size].pumpSize + " != " + obj.pumpSize); t.equal(res[size].outOfService, obj.outOfService, res[size].outOfService + " != " + obj.outOfService); From 7d9ca39278d13fadf25256eff8467c39f5c75fe9 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Mon, 4 May 2020 11:11:27 -0400 Subject: [PATCH 196/217] Added decibels method, working on unit and bindings tests --- bindings/calculator.h | 22 +++++- include/calculator/util/CompressedAir.h | 45 +++++++++++- .../calculator/util/CompressedAirReduction.h | 50 +++++++++---- src/calculator/util/CompressedAir.cpp | 38 +++++++++- .../util/CompressedAirReduction.cpp | 71 ++++++++++++++++++- tests/CompressedAir.unit.cpp | 10 +++ tests/CompressedAirReduction.unit.cpp | 39 +++++++--- tests/js/calculator.js | 55 ++++++++++++-- 8 files changed, 298 insertions(+), 32 deletions(-) diff --git a/bindings/calculator.h b/bindings/calculator.h index 39996884..3a3418aa 100644 --- a/bindings/calculator.h +++ b/bindings/calculator.h @@ -552,9 +552,27 @@ DecibelsMethodData getDecibelsMethodData(Local obj) { ThrowTypeError(std::string("CompressedAirReduction: getDecibelsMethodData method in calculator.h: decibelsMethodData not present in object").c_str()); } - double leakRateEstimate = GetDouble("soundIntensity", decibelsMethodDataV8); + double linePressure = GetDouble("linePressure", decibelsMethodDataV8); + double decibels = GetDouble("decibels", decibelsMethodDataV8); + double decibelRatingA = GetDouble("decibelRatingA", decibelsMethodDataV8); + double pressureA = GetDouble("pressureA", decibelsMethodDataV8); + double firstFlowA = GetDouble("firstFlowA", decibelsMethodDataV8); + double secondFlowA = GetDouble("secondFlowA", decibelsMethodDataV8); + double decibelRatingB = GetDouble("decibelRatingB", decibelsMethodDataV8); + double pressureB = GetDouble("pressureB", decibelsMethodDataV8); + double firstFlowB = GetDouble("firstFlowB", decibelsMethodDataV8); + double secondFlowB = GetDouble("secondFlowB", decibelsMethodDataV8); return { - leakRateEstimate}; + linePressure, + decibels, + decibelRatingA, + pressureA, + firstFlowA, + secondFlowA, + decibelRatingB, + pressureB, + firstFlowB, + secondFlowB}; } EstimateMethodData getEstimateMethodData(Local obj) diff --git a/include/calculator/util/CompressedAir.h b/include/calculator/util/CompressedAir.h index f7647905..12375006 100644 --- a/include/calculator/util/CompressedAir.h +++ b/include/calculator/util/CompressedAir.h @@ -409,7 +409,50 @@ class EstimateMethod { }; class DecibelsMethod { - // + public: + struct Output { + Output(const double leakRateEstimate, const double annualConsumption) + : leakRateEstimate(leakRateEstimate), annualConsumption(annualConsumption) + {} + + const double leakRateEstimate, annualConsumption; + }; + + /** + * Constructor for DecibelsMethod - The decibels method estimates the air loss by using decibel and line pressure measurements + * @param operatingTime double, operating time of the system per year - hours + * @param linePressure double, + * @param decibels double, + * @param decibelRatingA double, + * @param pressureA double, + * @param firstFlowA double, + * @param secondFlowA double, + * @param decibelRatingB double, + * @param pressureB double, + * @param firstFlowB double, + * @param secondFlowB double, + */ + DecibelsMethod(const double operatingTime, const double linePressure, const double decibels, const double decibelRatingA, + const double pressureA, const double firstFlowA, const double secondFlowA, const double decibelRatingB, const double pressureB, + const double firstFlowB, const double secondFlowB); + + /** + * @return DecibelsMethod::Output, leak rate estimate, annual consumption + */ + Output calculate(); + + private: + double operatingTime; + double linePressure; // X + double decibels; // Y + double decibelRatingA; // Y1 + double pressureA; // X1 + double firstFlowA; // Q11 + double secondFlowA; // Q21 + double decibelRatingB; // Y2 + double pressureB; // X2 + double firstFlowB; // Q12 + double secondFlowB; // Q22 }; class OrificeMethod { diff --git a/include/calculator/util/CompressedAirReduction.h b/include/calculator/util/CompressedAirReduction.h index c6f502ee..242cd85d 100644 --- a/include/calculator/util/CompressedAirReduction.h +++ b/include/calculator/util/CompressedAirReduction.h @@ -58,22 +58,48 @@ class PressureMethodData class DecibelsMethodData { public: - DecibelsMethodData(const double soundIntensity) : soundIntensity(soundIntensity) {} + DecibelsMethodData(const double linePressure, const double decibels, const double decibelRatingA, + const double pressureA, const double firstFlowA, const double secondFlowA, const double decibelRatingB, const double pressureB, + const double firstFlowB, const double secondFlowB) + : linePressure(linePressure), decibels(decibels), decibelRatingA(decibelRatingA), + pressureA(pressureA), firstFlowA(firstFlowA), secondFlowA(secondFlowA), decibelRatingB(decibelRatingB), + pressureB(pressureB), firstFlowB(firstFlowB), secondFlowB(secondFlowB) {} + + double getLinePressure() const { return linePressure; } + double getDecibels() const { return decibels; } + double getDecibelRatingA() const { return decibelRatingA; } + double getPressureA() const { return pressureA; } + double getFirstFlowA() const { return firstFlowA; } + double getSecondFlowA() const { return secondFlowA; } + double getDecibelRatingB() const { return decibelRatingB; } + double getPressureB() const { return pressureB; } + double getFirstFlowB() const { return firstFlowB; } + double getSecondFlowB() const { return secondFlowB; } + + void setLinePressure(double linePressure); + void setDecibels(double decibels); + void setDecibelRatingA(double decibelRatingA); + void setPressureA(double pressureA); + void setFirstFlowA(double firstFlowA); + void setSecondFlowA(double secondFlowA); + void setDecibelRatingB(double decibelRatingB); + void setPressureB(double pressureB); + void setFirstFlowB(double firstFlowB); + void setSecondFlowB(double secondFlowB); double calculate(); private: - double soundIntensity; - double linePressure; - double decibels; - double decibelRatingA; // y1 - double presureA; // x1 - double firstFlowA; // q11 - double secondFlowA; // q22 - double decibelRatingB; - double presureB; - double firstFlowB; - double secondFlowB; + double linePressure; // X + double decibels; // Y + double decibelRatingA; // Y1 + double pressureA; // X1 + double firstFlowA; // Q11 + double secondFlowA; // Q21 + double decibelRatingB; // Y2 + double pressureB; // X2 + double firstFlowB; // Q12 + double secondFlowB; // Q22 }; class EstimateMethodData diff --git a/src/calculator/util/CompressedAir.cpp b/src/calculator/util/CompressedAir.cpp index 408e3148..554013dd 100644 --- a/src/calculator/util/CompressedAir.cpp +++ b/src/calculator/util/CompressedAir.cpp @@ -182,6 +182,40 @@ EstimateMethod::Output EstimateMethod::calculate() { return output; } +DecibelsMethod::DecibelsMethod(const double operatingTime, const double linePressure, const double decibels, const double decibelRatingA, + const double pressureA, const double firstFlowA, const double secondFlowA, const double decibelRatingB, const double pressureB, + const double firstFlowB, const double secondFlowB) + : operatingTime(operatingTime), linePressure(linePressure), decibels(decibels), decibelRatingA(decibelRatingA), + pressureA(pressureA), firstFlowA(firstFlowA), secondFlowA(secondFlowA), decibelRatingB(decibelRatingB), + pressureB(pressureB), firstFlowB(firstFlowB), secondFlowB(secondFlowB) +{} + +DecibelsMethod::Output DecibelsMethod::calculate() { + /* + double operatingTime; + double linePressure; // X + double decibels; // Y + double decibelRatingA; // Y1 + double pressureA; // X1 + double firstFlowA; // Q11 + double secondFlowA; // Q21 + double decibelRatingB; // Y2 + double pressureB; // X2 + double firstFlowB; // Q12 + double secondFlowB; // Q22 + */ + + const double denominator = (pressureB - pressureA) * (decibelRatingB - decibelRatingA); + const double leakRateEstimate = ((pressureB - linePressure) * (decibelRatingB - decibels)) / denominator * firstFlowA + + ((linePressure - pressureA) * (decibelRatingB - decibels)) / denominator * secondFlowA + + ((pressureB - linePressure) * (decibels - decibelRatingA)) / denominator * firstFlowB + + ((linePressure - pressureA) * (decibels - decibelRatingA)) / denominator * secondFlowB; + const double annualConsumption = (leakRateEstimate * operatingTime * 60) / 1000; + DecibelsMethod::Output output(leakRateEstimate, annualConsumption); + + return output; +} + OrificeMethod::OrificeMethod(const double operatingTime, const double airTemp, const double atmPressure, const double dischargeCoef, const double diameter, const double supplyPressure, const int numOrifices) : operatingTime(operatingTime), airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), @@ -195,8 +229,8 @@ OrificeMethod::Output OrificeMethod::calculate() { const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; const double leakRateScfm = leakRateLBMmin / standardDensity; const double leakRateEstimate = leakRateScfm * numOrifices; - const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; - OrificeMethod::Output output(standardDensity, sonicDensity, leakVelocity, leakRateLBMmin, leakRateScfm, leakRateEstimate, annualComsumption); + const double annualConsumption = (operatingTime * leakRateEstimate * 60) / 1000; + OrificeMethod::Output output(standardDensity, sonicDensity, leakVelocity, leakRateLBMmin, leakRateScfm, leakRateEstimate, annualConsumption); return output; } diff --git a/src/calculator/util/CompressedAirReduction.cpp b/src/calculator/util/CompressedAirReduction.cpp index ab7b44ed..53bbd1a7 100644 --- a/src/calculator/util/CompressedAirReduction.cpp +++ b/src/calculator/util/CompressedAirReduction.cpp @@ -46,19 +46,21 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() { OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); tmpFlowRate = orificeMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) / 1000; // / 1000? + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? } // decibels method else if(compressedAirReductionInput.getMeasurementMethod() == 5) { DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); + tmpFlowRate = decibelsMethodData.calculate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? } // estimate method else if(compressedAirReductionInput.getMeasurementMethod() == 6) { EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); tmpFlowRate = estimateMethodData.getLeakRateEstimate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) / 1000; // / 1000? + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? } //electricity calculation @@ -108,6 +110,30 @@ double PressureMethodData::calculate() return singleNozzleFlowRate; } +double DecibelsMethodData::calculate() +{ + /* + double linePressure; // X + double decibels; // Y + double decibelRatingA; // Y1 + double pressureA; // X1 + double firstFlowA; // Q11 + double secondFlowA; // Q21 + double decibelRatingB; // Y2 + double pressureB; // X2 + double firstFlowB; // Q12 + double secondFlowB; // Q22 + */ + + const double denominator = (pressureB - pressureA) * (decibelRatingB - decibelRatingA); + const double leakRateEstimate = ((pressureB - linePressure) * (decibelRatingB - decibels)) / denominator * firstFlowA + + ((linePressure - pressureA) * (decibelRatingB - decibels)) / denominator * secondFlowA + + ((pressureB - linePressure) * (decibels - decibelRatingA)) / denominator * firstFlowB + + ((linePressure - pressureA) * (decibels - decibelRatingA)) / denominator * secondFlowB; + + return leakRateEstimate; +} + double OrificeMethodData::calculate() { const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); @@ -192,6 +218,47 @@ void OrificeMethodData::setNumOrifices(const int numOrifices) this->numOrifices = numOrifices; } +void DecibelsMethodData::setLinePressure(double linePressure) +{ + this->linePressure = linePressure; +} +void DecibelsMethodData::setDecibels(double decibels) +{ + this->decibels = decibels; +} +void DecibelsMethodData::setDecibelRatingA(double decibelRatingA) +{ + this->decibelRatingA = decibelRatingA; +} +void DecibelsMethodData::setPressureA(double pressureA) +{ + this->pressureA = pressureA; +} +void DecibelsMethodData::setFirstFlowA(double firstFlowA) +{ + this->firstFlowA = firstFlowA; +} +void DecibelsMethodData::setSecondFlowA(double secondFlowA) +{ + this->secondFlowA = secondFlowA; +} +void DecibelsMethodData::setDecibelRatingB(double decibelRatingB) +{ + this->decibelRatingB = decibelRatingB; +} +void DecibelsMethodData::setPressureB(double pressureB) +{ + this->pressureB = pressureB; +} +void DecibelsMethodData::setFirstFlowB(double firstFlowB) +{ + this->firstFlowB = firstFlowB; +} +void DecibelsMethodData::setSecondFlowB(double secondFlowB) +{ + this->secondFlowB = secondFlowB; +} + void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) { this->leakRateEstimate = leakRateEstimate; diff --git a/tests/CompressedAir.unit.cpp b/tests/CompressedAir.unit.cpp index 99c1735a..65b17ef3 100644 --- a/tests/CompressedAir.unit.cpp +++ b/tests/CompressedAir.unit.cpp @@ -200,6 +200,16 @@ TEST_CASE( "Estimate Method", "[CompressedAir][EstimateMethod]") { //compare(EstimateMethod(EstimateMethod::LeakEstimateType::Small, 115200 / 60.0).calculate(), EstimateMethod::Output(5.25)); //compare(EstimateMethod(EstimateMethod::LeakEstimateType::Small, 115200 / 60.0).calculate(), EstimateMethod::Output(1.092)); CHECK(EstimateMethod(1280, 0.1).calculate().annualConsumption == Approx(EstimateMethod::Output(7.68).annualConsumption)); + CHECK(EstimateMethod(1280, 1.429).calculate().annualConsumption == Approx(EstimateMethod::Output(109.7472).annualConsumption)); +} + +TEST_CASE( "Decibels Method", "[CompressedAir][DecibelsMethod]") { + auto const compare = [](DecibelsMethod::Output const & results, DecibelsMethod::Output const & expected) { + CHECK(expected.leakRateEstimate == Approx(results.leakRateEstimate)); + CHECK(expected.annualConsumption == Approx(results.annualConsumption)); + }; + + compare(DecibelsMethod(1280, 130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65).calculate(), DecibelsMethod::Output(1.429, 109.7472)); } TEST_CASE( "Orifice Method", "[CompressedAir][OrificeMethod]") { diff --git a/tests/CompressedAirReduction.unit.cpp b/tests/CompressedAirReduction.unit.cpp index c7382788..f1e19075 100644 --- a/tests/CompressedAirReduction.unit.cpp +++ b/tests/CompressedAirReduction.unit.cpp @@ -10,7 +10,7 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method", "[CompressedAirReduction PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(1.428, 1.38233), 1)}; @@ -33,7 +33,7 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method and Electricity", "[Compre PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(0.8, 0.16), 1)}; @@ -56,7 +56,7 @@ TEST_CASE("Compressed Air Reduction Bag Method and Electricity", "[CompressedAir PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 2)}; @@ -70,7 +70,7 @@ TEST_CASE("Compressed Air Reduction Bag Method and Electricity", "[CompressedAir CHECK(testOutput.consumption == Approx(3534291.73528)); } -TEST_CASE("Compressed Air Reduction Orifice Pressure Method and Electricity", "[CompressedAirReduction][Util]") +TEST_CASE("Compressed Air Reduction Pressure Method and Electricity", "[CompressedAirReduction][Util]") { std::vector compressedAirReductionInputVec = { CompressedAirReductionInput(8640, 1, 0.12, 2, @@ -79,7 +79,7 @@ TEST_CASE("Compressed Air Reduction Orifice Pressure Method and Electricity", "[ PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; @@ -93,7 +93,7 @@ TEST_CASE("Compressed Air Reduction Orifice Pressure Method and Electricity", "[ CHECK(testOutput.consumption == Approx(921978.5471999)); } -TEST_CASE("Compressed Air Reduction Orifice Pressure Method Multiple Nozzles", "[CompressedAirReduction][Util]") +TEST_CASE("Compressed Air Reduction Pressure Method Multiple Nozzles", "[CompressedAirReduction][Util]") { std::vector compressedAirReductionInputVec = { CompressedAirReductionInput(8640, 1, 0.12, 2, @@ -102,7 +102,7 @@ TEST_CASE("Compressed Air Reduction Orifice Pressure Method Multiple Nozzles", " PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 3)}; @@ -125,7 +125,7 @@ TEST_CASE("Compressed Air Reduction Other Method", "[CompressedAirReduction][Uti PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(1.0), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; @@ -135,4 +135,27 @@ TEST_CASE("Compressed Air Reduction Other Method", "[CompressedAirReduction][Uti CHECK(testOutput.consumption == Approx(200000.00)); CHECK(testOutput.energyUse == Approx(213.3333)); CHECK(testOutput.energyCost == Approx(25.6)); +} + +TEST_CASE("Compressed Air Reduction Orifice Method and Electricity", "[CompressedAirReduction][Util]") +{ + std::vector compressedAirReductionInputVec = { + CompressedAirReductionInput(8640, 1, 0.12, 4, + CompressedAirFlowMeterMethodData(200000), + BagMethodData(15, 10, 12), + PressureMethodData(0, 1, 80), + CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + EstimateMethodData(0.1), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); + auto testOutput = compressedAirReduction.calculate(); + CHECK(testOutput.energyUse == Approx(1253583.3379004421)); + CHECK(testOutput.energyCost == Approx(150430.000548053)); + CHECK(testOutput.flowRate == Approx(2267.0416267007)); + CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); + CHECK(testOutput.consumption == Approx(1175234379)); } \ No newline at end of file diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 78f84703..3dce2754 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -273,7 +273,16 @@ test('Compressed Air Reduction Basic Test', function (t) { numberOfOrifices: 1 }, decibelsMethodData: { - soundIntensity: 0 + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 }, estimateMethodData: { leakRateEstimate: 0 @@ -337,7 +346,16 @@ test('Compressed Air Reduction Test All', function (t) { numberOfOrifices: 1 }, decibelsMethodData: { - soundIntensity: 0 + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 }, estimateMethodData: { leakRateEstimate: 0 @@ -384,7 +402,16 @@ test('Compressed Air Reduction Test All', function (t) { numberOfOrifices: 1 }, decibelsMethodData: { - soundIntensity: 0 + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 }, estimateMethodData: { leakRateEstimate: 0 @@ -429,7 +456,16 @@ test('Compressed Air Reduction Test All', function (t) { numberOfOrifices: 1 }, decibelsMethodData: { - soundIntensity: 0 + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 }, estimateMethodData: { leakRateEstimate: 0 @@ -474,7 +510,16 @@ test('Compressed Air Reduction Test All', function (t) { numberOfOrifices: 1 }, decibelsMethodData: { - soundIntensity: 0 + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 }, estimateMethodData: { leakRateEstimate: 0 From 220c34c9b07b5aa5fcf724396fbe0a74cea2bbf5 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 5 May 2020 12:55:45 -0400 Subject: [PATCH 197/217] Added and updated unit and bindings tests --- .../util/CompressedAirReduction.cpp | 6 +- tests/CompressedAirReduction.unit.cpp | 66 +++++++++++++++++++ tests/js/calculator.js | 10 +-- 3 files changed, 74 insertions(+), 8 deletions(-) diff --git a/src/calculator/util/CompressedAirReduction.cpp b/src/calculator/util/CompressedAirReduction.cpp index 53bbd1a7..0a826de3 100644 --- a/src/calculator/util/CompressedAirReduction.cpp +++ b/src/calculator/util/CompressedAirReduction.cpp @@ -46,21 +46,21 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() { OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); tmpFlowRate = orificeMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); } // decibels method else if(compressedAirReductionInput.getMeasurementMethod() == 5) { DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); tmpFlowRate = decibelsMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); } // estimate method else if(compressedAirReductionInput.getMeasurementMethod() == 6) { EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); tmpFlowRate = estimateMethodData.getLeakRateEstimate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); // / 1000? + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); } //electricity calculation diff --git a/tests/CompressedAirReduction.unit.cpp b/tests/CompressedAirReduction.unit.cpp index f1e19075..70b39340 100644 --- a/tests/CompressedAirReduction.unit.cpp +++ b/tests/CompressedAirReduction.unit.cpp @@ -158,4 +158,70 @@ TEST_CASE("Compressed Air Reduction Orifice Method and Electricity", "[Compresse CHECK(testOutput.flowRate == Approx(2267.0416267007)); CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); CHECK(testOutput.consumption == Approx(1175234379)); +} + +TEST_CASE("Compressed Air Reduction Decibels Method and Electricity", "[CompressedAirReduction][Util]") +{ + std::vector compressedAirReductionInputVec = { + CompressedAirReductionInput(8640, 1, 0.12, 5, + CompressedAirFlowMeterMethodData(200000), + BagMethodData(15, 10, 12), + PressureMethodData(0, 1, 80), + CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + EstimateMethodData(0.1), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); + auto testOutput = compressedAirReduction.calculate(); + CHECK(testOutput.energyUse == Approx(790.17984)); + CHECK(testOutput.energyCost == Approx(94.8215808)); + CHECK(testOutput.flowRate == Approx(1.429)); + CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); + CHECK(testOutput.consumption == Approx(740793.6)); +} + +TEST_CASE("Compressed Air Reduction Estimate Method and Electricity", "[CompressedAirReduction][Util]") +{ + std::vector compressedAirReductionInputVec = { + CompressedAirReductionInput(8640, 1, 0.12, 6, + CompressedAirFlowMeterMethodData(200000), + BagMethodData(15, 10, 12), + PressureMethodData(0, 1, 80), + CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + EstimateMethodData(0.1), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); + auto testOutput = compressedAirReduction.calculate(); + CHECK(testOutput.energyUse == Approx(55.296)); + CHECK(testOutput.energyCost == Approx(6.63552)); + CHECK(testOutput.flowRate == Approx(0.1)); + CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); + CHECK(testOutput.consumption == Approx(51840)); + + compressedAirReductionInputVec = { + CompressedAirReductionInput(3840, 1, 0.12, 6, + CompressedAirFlowMeterMethodData(200000), + BagMethodData(15, 10, 12), + PressureMethodData(0, 1, 80), + CompressedAirOtherMethodData(200000), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + EstimateMethodData(0.1), + CompressorElectricityData(0.25, 0.16), + 1)}; + + compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); + testOutput = compressedAirReduction.calculate(); + CHECK(testOutput.energyUse == Approx(15.36)); + CHECK(testOutput.energyCost == Approx(1.8432)); + CHECK(testOutput.flowRate == Approx(0.1)); + CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); + CHECK(testOutput.consumption == Approx(23040)); } \ No newline at end of file diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 3dce2754..71a8fc19 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -285,7 +285,7 @@ test('Compressed Air Reduction Basic Test', function (t) { secondFlowB: 1.65 }, estimateMethodData: { - leakRateEstimate: 0 + leakRateEstimate: 0.1 }, compressorElectricityData: { compressorControlAdjustment: 0.8, @@ -358,7 +358,7 @@ test('Compressed Air Reduction Test All', function (t) { secondFlowB: 1.65 }, estimateMethodData: { - leakRateEstimate: 0 + leakRateEstimate: 0.1 }, compressorElectricityData: { compressorControlAdjustment: 0.8, @@ -414,7 +414,7 @@ test('Compressed Air Reduction Test All', function (t) { secondFlowB: 1.65 }, estimateMethodData: { - leakRateEstimate: 0 + leakRateEstimate: 0.1 }, compressorElectricityData: { compressorControlAdjustment: 0.8, @@ -468,7 +468,7 @@ test('Compressed Air Reduction Test All', function (t) { secondFlowB: 1.65 }, estimateMethodData: { - leakRateEstimate: 0 + leakRateEstimate: 0.1 }, compressorElectricityData: { compressorControlAdjustment: 0.8, @@ -522,7 +522,7 @@ test('Compressed Air Reduction Test All', function (t) { secondFlowB: 1.65 }, estimateMethodData: { - leakRateEstimate: 0 + leakRateEstimate: 0.1 }, compressorElectricityData: { compressorControlAdjustment: 0.8, From 43ba74f971c77dae07c8a29f9a081d5c0ab7cd35 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 6 May 2020 13:27:50 -0400 Subject: [PATCH 198/217] Started overhaul --- CMakeLists.txt | 2 + bindings/calculator.h | 1 + .../calculator/util/CompressedAirLeakSurvey.h | 246 ++++++++++++++++ .../util/CompressedAirLeakSurvey.cpp | 272 ++++++++++++++++++ tests/js/calculator.js | 67 +++++ 5 files changed, 588 insertions(+) create mode 100644 include/calculator/util/CompressedAirLeakSurvey.h create mode 100644 src/calculator/util/CompressedAirLeakSurvey.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d469bc2..cfa999ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,7 @@ set(SOURCE_FILES src/calculator/util/NaturalGasReduction.cpp src/calculator/util/CompressedAirReduction.cpp src/calculator/util/CompressedAirPressureReduction.cpp + src/calculator/util/CompressedAirLeakSurvey.cpp src/calculator/util/WaterReduction.cpp src/calculator/util/insulation/pipes/InsulatedPipeInput.cpp src/calculator/util/insulation/pipes/InsulatedPipeCalculator.cpp @@ -352,6 +353,7 @@ set(INCLUDE_FILES include/calculator/util/ElectricityReduction.h include/calculator/util/NaturalGasReduction.h include/calculator/util/CompressedAirReduction.h + include/calculator/util/CompressedAirLeakSurvey.h include/calculator/util/CompressedAirPressureReduction.h include/calculator/util/WaterReduction.h include/calculator/util/insulation/pipes/InsulatedPipeInput.h diff --git a/bindings/calculator.h b/bindings/calculator.h index 3a3418aa..bfeffce5 100644 --- a/bindings/calculator.h +++ b/bindings/calculator.h @@ -601,6 +601,7 @@ CompressorElectricityData getCompressorElectricityData(Local obj) ThrowTypeError(std::string("CompressedAirReduction: getCompressorElectricityData method in calculator.h: compressorElectricityData not present in object").c_str()); } double compressorControlAdjustment = Conversion(GetDouble("compressorControlAdjustment", compressorElectricityDataV8)).percentToFraction(); + //double compressorControlAdjustment = GetDouble("compressorControlAdjustment", compressorElectricityDataV8); double compressorSpecificPower = GetDouble("compressorSpecificPower", compressorElectricityDataV8); return { compressorControlAdjustment, diff --git a/include/calculator/util/CompressedAirLeakSurvey.h b/include/calculator/util/CompressedAirLeakSurvey.h new file mode 100644 index 00000000..5084a1d2 --- /dev/null +++ b/include/calculator/util/CompressedAirLeakSurvey.h @@ -0,0 +1,246 @@ +/* +#ifndef AMO_LIBRARY_COMPRESSEDAIRLEAKSURVEY_H +#define AMO_LIBRARY_COMPRESSEDAIRLEAKSURVEY_H + +#include +#include +#include + +class CompressedAirFlowMeterMethodData +{ + public: + CompressedAirFlowMeterMethodData(const double meterReading) + : meterReading(meterReading) {} + + double getMeterReading() const { return meterReading; } + void setMeterReading(double meterReading); + + private: + double meterReading; +}; + +class BagMethodData +{ + public: + BagMethodData(const double height, const double diameter, const double fillTime) + : height(height), diameter(diameter), fillTime(fillTime) {} + + double getHeight() const { return height; } + double getDiameter() const { return diameter; } + double getFillTime() const { return fillTime; } + void setHeight(double height); + void setDiameter(double diameter); + void setFillTime(double fillTime); + + private: + double height, diameter, fillTime; +}; + +class PressureMethodData +{ + public: + PressureMethodData(const int nozzleType, const int numberOfNozzles, const double supplyPressure) + : nozzleType(nozzleType), numberOfNozzles(numberOfNozzles), supplyPressure(supplyPressure) {} + + int getNozzleType() const { return nozzleType; } + int getNumberOfNozzles() const { return numberOfNozzles; } + double getSupplyPressure() const { return supplyPressure; } + void setNozzleType(int nozzleType); + void setNumberOfNozzles(int numberOfNozzles); + void setSupplyPressure(double supplyPressure); + + double calculate(); + + private: + int nozzleType, numberOfNozzles; + double supplyPressure; +}; + +class DecibelsMethodData +{ + public: + DecibelsMethodData(const double linePressure, const double decibels, const double decibelRatingA, + const double pressureA, const double firstFlowA, const double secondFlowA, const double decibelRatingB, const double pressureB, + const double firstFlowB, const double secondFlowB) + : linePressure(linePressure), decibels(decibels), decibelRatingA(decibelRatingA), + pressureA(pressureA), firstFlowA(firstFlowA), secondFlowA(secondFlowA), decibelRatingB(decibelRatingB), + pressureB(pressureB), firstFlowB(firstFlowB), secondFlowB(secondFlowB) {} + + double getLinePressure() const { return linePressure; } + double getDecibels() const { return decibels; } + double getDecibelRatingA() const { return decibelRatingA; } + double getPressureA() const { return pressureA; } + double getFirstFlowA() const { return firstFlowA; } + double getSecondFlowA() const { return secondFlowA; } + double getDecibelRatingB() const { return decibelRatingB; } + double getPressureB() const { return pressureB; } + double getFirstFlowB() const { return firstFlowB; } + double getSecondFlowB() const { return secondFlowB; } + + void setLinePressure(double linePressure); + void setDecibels(double decibels); + void setDecibelRatingA(double decibelRatingA); + void setPressureA(double pressureA); + void setFirstFlowA(double firstFlowA); + void setSecondFlowA(double secondFlowA); + void setDecibelRatingB(double decibelRatingB); + void setPressureB(double pressureB); + void setFirstFlowB(double firstFlowB); + void setSecondFlowB(double secondFlowB); + + double calculate(); + + private: + double linePressure; // X + double decibels; // Y + double decibelRatingA; // Y1 + double pressureA; // X1 + double firstFlowA; // Q11 + double secondFlowA; // Q21 + double decibelRatingB; // Y2 + double pressureB; // X2 + double firstFlowB; // Q12 + double secondFlowB; // Q22 +}; + +class EstimateMethodData +{ + public: + EstimateMethodData(const double leakRateEstimate) : leakRateEstimate(leakRateEstimate) {} + + double getLeakRateEstimate() const {return leakRateEstimate; } + void setLeakRateEstimate(double leakRateEstimate); + + private: + double leakRateEstimate; +}; + +class OrificeMethodData +{ + public: + OrificeMethodData(const double airTemp, const double atmPressure, const double dischargeCoef, // removed operatingTime + const double diameter, const double supplyPressure, const int numOrifices) + : airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), + supplyPressure(supplyPressure), numOrifices(numOrifices) {} + + double getAirTemp() const { return airTemp; } + double getAtmPressure() const { return atmPressure; } + double getDischargeCoef() const { return dischargeCoef; } + double getDiameter() const { return diameter; } + double getSupplyPressure() const { return supplyPressure; } + int getNumOrifices() const { return numOrifices; } + + void setAirTemp(double airTemp); + void setAtmPressure(double atmPressure); + void setDischargeCoef(double dischargeCoef); + void setDiameter(double diameter); + void setSupplyPressure(double supplyPressure); + void setNumOrifices(int numOrifices); + + double calculate(); + + private: + double airTemp, atmPressure, dischargeCoef, diameter, supplyPressure; + int numOrifices; +}; + +class CompressedAirOtherMethodData +{ + public: + CompressedAirOtherMethodData(const double consumption) + : consumption(consumption) {} + + double getConsumption() const { return consumption; } + void setConsumption(double consumption); + + private: + double consumption; +}; + +//calculates electricity use for a compressor if utilityType == electricity +class CompressorElectricityData +{ + public: + CompressorElectricityData(const double compressorControlAdjustment, const double compressorSpecificPower) + : compressorControlAdjustment(compressorControlAdjustment), compressorSpecificPower(compressorSpecificPower) {} + + double calculate(); + + private: + double compressorControlAdjustment, compressorSpecificPower; +}; + +class CompressedAirReductionInput +{ + public: + CompressedAirReductionInput(const int hoursPerYear, const int utilityType, const double utilityCost, const int measurementMethod, + const CompressedAirFlowMeterMethodData flowMeterMethodData, const BagMethodData bagMethodData, + const PressureMethodData pressureMethodData, const CompressedAirOtherMethodData otherMethodData, + const OrificeMethodData orificeMethodData, const DecibelsMethodData decibelsMethodData, + const EstimateMethodData estimateMethodData, const CompressorElectricityData compressorElectricityData, + const int units) + : hoursPerYear(hoursPerYear), utilityType(utilityType), utilityCost(utilityCost), measurementMethod(measurementMethod), + flowMeterMethodData(flowMeterMethodData), bagMethodData(bagMethodData), + pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), orificeMethodData(orificeMethodData), + decibelsMethodData(decibelsMethodData), estimateMethodData(estimateMethodData), + compressorElectricityData(compressorElectricityData), units(units) {} + + int getHoursPerYear() const { return hoursPerYear; } // operating time + int getUtilityType() const { return utilityType; } + int getMeasurementMethod() const { return measurementMethod; } + int getUnits() const { return units; } + double getUtilityCost() const { return utilityCost; } + CompressedAirFlowMeterMethodData getFlowMeterMethodData() const { return flowMeterMethodData; } + BagMethodData getBagMethodData() const { return bagMethodData; } + PressureMethodData getPressureMethodData() const { return pressureMethodData; } + CompressedAirOtherMethodData getOtherMethodData() const { return otherMethodData; } + OrificeMethodData getOrificeMethodData() const { return orificeMethodData; } + DecibelsMethodData getDecibelsMethodData() const { return decibelsMethodData; } + EstimateMethodData getEstimateMethodData() const { return estimateMethodData; } + CompressorElectricityData getCompressorElectricityData() const { return compressorElectricityData; } + + private: + int hoursPerYear, utilityType; + double utilityCost; + int measurementMethod; + CompressedAirFlowMeterMethodData flowMeterMethodData; + BagMethodData bagMethodData; + PressureMethodData pressureMethodData; + CompressedAirOtherMethodData otherMethodData; + OrificeMethodData orificeMethodData; + DecibelsMethodData decibelsMethodData; + EstimateMethodData estimateMethodData; + CompressorElectricityData compressorElectricityData; + int units; +}; + +class CompressedAirReduction +{ + public: + struct Output + { + Output(double energyUse, double energyCost, double flowRate, double singleNozzleFlowRate, double consumption) + : energyUse(energyUse), energyCost(energyCost), flowRate(flowRate), singleNozzleFlowRate(singleNozzleFlowRate), consumption(consumption) {} + + Output() = default; + double energyUse = 0, energyCost = 0, flowRate = 0, singleNozzleFlowRate, consumption = 0; + }; + + CompressedAirReduction(std::vector &compressedAirReductionInputVec) : compressedAirReductionInputVec(compressedAirReductionInputVec) + { + } + + CompressedAirReduction::Output calculate(); + std::vector const &getCompressedAirReductionInputVec() const + { + return compressedAirReductionInputVec; + } + void setCompressedAirReductionInputVec(std::vector &compressedAirReductionInputVec); + + private: + std::vector compressedAirReductionInputVec; + CompressedAirReduction::Output output; +}; + +#endif // AMO_LIBRARY_COMPRESSEDAIRLeakSurvey_H +*/ \ No newline at end of file diff --git a/src/calculator/util/CompressedAirLeakSurvey.cpp b/src/calculator/util/CompressedAirLeakSurvey.cpp new file mode 100644 index 00000000..791b6622 --- /dev/null +++ b/src/calculator/util/CompressedAirLeakSurvey.cpp @@ -0,0 +1,272 @@ +/* +#include +#include +#include "calculator/util/CompressedAirLeakSurvey.h" +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +CompressedAirReduction::Output CompressedAirReduction::calculate() +{ + double totalEnergyUse = 0, totalEnergyCost = 0, totalFlowRate = 0, singleNozzleFlowRate = 0, totalConsumption = 0; + + for (auto &compressedAirReductionInput : compressedAirReductionInputVec) + { + double tmpEnergyUse = 0, tmpEnergyCost = 0, tmpFlowRate = 0, tmpSingleNozzleFlowRate = 0, tmpTotalConsumption = 0; + + // compressed air flow meter + if (compressedAirReductionInput.getMeasurementMethod() == 0) + { + CompressedAirFlowMeterMethodData flowMeterMethodData = compressedAirReductionInput.getFlowMeterMethodData(); + tmpTotalConsumption = flowMeterMethodData.getMeterReading() * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); + tmpFlowRate = flowMeterMethodData.getMeterReading(); + } + // bag method + else if (compressedAirReductionInput.getMeasurementMethod() == 1) + { + BagMethodData bagMethodData = compressedAirReductionInput.getBagMethodData(); + tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); + tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); + } + // pressure method + else if (compressedAirReductionInput.getMeasurementMethod() == 2) + { + PressureMethodData pressureMethodData = compressedAirReductionInput.getPressureMethodData(); + tmpSingleNozzleFlowRate = pressureMethodData.calculate(); + tmpFlowRate = tmpSingleNozzleFlowRate * pressureMethodData.getNumberOfNozzles(); + tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear(); + } + // other method + else if (compressedAirReductionInput.getMeasurementMethod() == 3) + { + CompressedAirOtherMethodData otherMethodData = compressedAirReductionInput.getOtherMethodData(); + tmpTotalConsumption = otherMethodData.getConsumption(); + } + // orifice method + else if(compressedAirReductionInput.getMeasurementMethod() == 4) + { + OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); + tmpFlowRate = orificeMethodData.calculate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); + } + // decibels method + else if(compressedAirReductionInput.getMeasurementMethod() == 5) + { + DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); + tmpFlowRate = decibelsMethodData.calculate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); + } + // estimate method + else if(compressedAirReductionInput.getMeasurementMethod() == 6) + { + EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); + tmpFlowRate = estimateMethodData.getLeakRateEstimate(); + tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); + } + + //electricity calculation + if (compressedAirReductionInput.getUtilityType() == 0) + { + tmpEnergyCost = compressedAirReductionInput.getUtilityCost() * tmpTotalConsumption; + } + else if (compressedAirReductionInput.getUtilityType() == 1) + { + CompressorElectricityData compressorElectricityData = compressedAirReductionInput.getCompressorElectricityData(); + double electricityCalculation = compressorElectricityData.calculate(); + tmpEnergyUse = electricityCalculation * tmpTotalConsumption; + tmpEnergyCost = tmpEnergyUse * compressedAirReductionInput.getUtilityCost(); + } + + totalEnergyUse += tmpEnergyUse; + totalEnergyCost += tmpEnergyCost; + totalFlowRate += tmpFlowRate; + singleNozzleFlowRate += tmpSingleNozzleFlowRate; + totalConsumption += tmpTotalConsumption; + } + + return CompressedAirReduction::Output(totalEnergyUse, totalEnergyCost, totalFlowRate, singleNozzleFlowRate, totalConsumption); +} + +double PressureMethodData::calculate() +{ + static double nozzleTable[13][3] = { + {-2.2e-07, 0.018893, 0.268476}, + {-2.8e-05, 0.038377, 1.061905}, + {-7.6e-05, 1.537424, 14.3}, + {-2.2e-05, 0.345931, 5.780952}, + {0.000682, 0.643182, 13.83333}, + {5.41e-06, 0.228851, 2.968095}, + {-2.1e-06, 0.075463, 1.089857}, + {-2.8e-05, 0.14871, 1.841905}, + {0.002652, 2.250152, 46.56667}, + {0.000747, 0.842056, 15.95714}, + {0.000411, 0.560649, 10.1619}, + {0.000935, 0.130792, 4.429524}, + {0.000935, 0.130792, 4.429524}}; + + const double a = nozzleTable[this->nozzleType][0]; + const double b = nozzleTable[this->nozzleType][1]; + const double c = nozzleTable[this->nozzleType][2]; + double singleNozzleFlowRate = (a * (pow(this->supplyPressure, 2.0))) + (b * this->supplyPressure) + c; + return singleNozzleFlowRate; +} + +double DecibelsMethodData::calculate() +{ + + //double linePressure; // X + //double decibels; // Y + //double decibelRatingA; // Y1 + //double pressureA; // X1 + //double firstFlowA; // Q11 + //double secondFlowA; // Q21 + //double decibelRatingB; // Y2 + //double pressureB; // X2 + //double firstFlowB; // Q12 + //double secondFlowB; // Q22 + + + const double denominator = (pressureB - pressureA) * (decibelRatingB - decibelRatingA); + const double leakRateEstimate = ((pressureB - linePressure) * (decibelRatingB - decibels)) / denominator * firstFlowA + + ((linePressure - pressureA) * (decibelRatingB - decibels)) / denominator * secondFlowA + + ((pressureB - linePressure) * (decibels - decibelRatingA)) / denominator * firstFlowB + + ((linePressure - pressureA) * (decibels - decibelRatingA)) / denominator * secondFlowB; + + return leakRateEstimate; +} + +double OrificeMethodData::calculate() +{ + const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); + const double sonicDensity = std::pow(standardDensity * (2 / (1.4 + 1)), 1/(1.4 - 1)); + const double leakVelocity = std::pow(((2 * 1.4) / (1.4 + 1)) * 53.34 * airTemp * 32.2, 0.5); + const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; + const double leakRateScfm = leakRateLBMmin / standardDensity; + const double leakRateEstimate = leakRateScfm * numOrifices; + //const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; + + return leakRateEstimate; +} + +double CompressorElectricityData::calculate() +{ + const double c = 1.0 / 60; + return c * this->compressorControlAdjustment * this->compressorSpecificPower; +} + +void CompressedAirReduction::setCompressedAirReductionInputVec(std::vector &compressedAirReductionInputVec) +{ + this->compressedAirReductionInputVec = std::move(compressedAirReductionInputVec); +} + +void CompressedAirOtherMethodData::setConsumption(const double consumption) +{ + this->consumption = consumption; +} + +void PressureMethodData::setNozzleType(const int nozzleType) +{ + this->nozzleType = nozzleType; +} + +void PressureMethodData::setNumberOfNozzles(const int numberOfNozzles) +{ + this->numberOfNozzles = numberOfNozzles; +} + +void PressureMethodData::setSupplyPressure(const double supplyPressure) +{ + this->supplyPressure = supplyPressure; +} + +void BagMethodData::setHeight(const double height) +{ + this->height = height; +} + +void BagMethodData::setDiameter(const double diameter) +{ + this->diameter = diameter; +} + +void BagMethodData::setFillTime(const double fillTime) +{ + this->fillTime = fillTime; +} + +void OrificeMethodData::setAirTemp(const double airTemp) +{ + this->airTemp = airTemp; +} +void OrificeMethodData::setAtmPressure(const double atmPressure) +{ + this->atmPressure = atmPressure; +} +void OrificeMethodData::setDischargeCoef(const double dischargeCoef) +{ + this->dischargeCoef = dischargeCoef; +} +void OrificeMethodData::setDiameter(const double diameter) +{ + this->diameter = diameter; +} +void OrificeMethodData::setSupplyPressure(const double supplyPressure) +{ + this->supplyPressure = supplyPressure; +} +void OrificeMethodData::setNumOrifices(const int numOrifices) +{ + this->numOrifices = numOrifices; +} + +void DecibelsMethodData::setLinePressure(double linePressure) +{ + this->linePressure = linePressure; +} +void DecibelsMethodData::setDecibels(double decibels) +{ + this->decibels = decibels; +} +void DecibelsMethodData::setDecibelRatingA(double decibelRatingA) +{ + this->decibelRatingA = decibelRatingA; +} +void DecibelsMethodData::setPressureA(double pressureA) +{ + this->pressureA = pressureA; +} +void DecibelsMethodData::setFirstFlowA(double firstFlowA) +{ + this->firstFlowA = firstFlowA; +} +void DecibelsMethodData::setSecondFlowA(double secondFlowA) +{ + this->secondFlowA = secondFlowA; +} +void DecibelsMethodData::setDecibelRatingB(double decibelRatingB) +{ + this->decibelRatingB = decibelRatingB; +} +void DecibelsMethodData::setPressureB(double pressureB) +{ + this->pressureB = pressureB; +} +void DecibelsMethodData::setFirstFlowB(double firstFlowB) +{ + this->firstFlowB = firstFlowB; +} +void DecibelsMethodData::setSecondFlowB(double secondFlowB) +{ + this->secondFlowB = secondFlowB; +} + +void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) +{ + this->leakRateEstimate = leakRateEstimate; +} + +void CompressedAirFlowMeterMethodData::setMeterReading(const double meterReading) +{ + this->meterReading = meterReading; +} +*/ \ No newline at end of file diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 71a8fc19..0eee61e6 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -303,7 +303,74 @@ test('Compressed Air Reduction Basic Test', function (t) { t.equal(rnd(res.singleNozzleFlowRate), rnd(0.0)); t.equal(rnd(res.consumption), rnd(103680000000.0)); }); +/* +test('Compressed Air Reduction Test (misc)', function (t) { + t.plan(6); + t.type(bindings.compressedAirReduction, 'function'); + var inp = { + compressedAirReductionInputVec: [ + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 5, + flowMeterMethodData: { + meterReading: 0 + }, + bagMethodData: { + height: 0, + diameter: 0, + fillTime: 0 + }, + pressureMethodData: { + nozzleType: 0, + numberOfNozzles: 1, + supplyPressure: 80 + }, + otherMethodData: { + consumption: 0 + }, + orificeMethodData: { + compressorAirTemp: 0, + atmosphericPressure: 0, + dischargeCoefficient: 0, + orificeDiameter: 0, + supplyPressure: 0, + numberOfOrifices: 0 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + estimateMethodData: { + leakRateEstimate: 0 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.4, + compressorSpecificPower: 0.16 + }, + units: 1 + } + ] + }; + + var res = bindings.compressedAirReduction(inp); + t.equal(rnd(res.energyUse), rnd(790.1798)); + t.equal(rnd(res.energyCost), rnd(94.8216)); + t.equal(rnd(res.flowRate), rnd(1.429)); + t.equal(rnd(res.singleNozzleFlowRate), rnd(0.0)); + t.equal(rnd(res.consumption), rnd(740793.6)); +}); +*/ test('Compressed Air Reduction Test All', function (t) { t.plan(6); t.type(bindings.compressedAirReduction, 'function'); From 1aaa8c393df5c36c54ae162802b53ca131a169a7 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 7 May 2020 00:01:04 -0400 Subject: [PATCH 199/217] Added Compressed Air Leak Survey --- CMakeLists.txt | 1 + bindings/calculator.cpp | 3 + bindings/calculator.h | 207 ++++++--- .../calculator/util/CompressedAirLeakSurvey.h | 147 ++----- .../calculator/util/CompressedAirReduction.h | 103 +---- .../util/CompressedAirLeakSurvey.cpp | 208 +++------ .../util/CompressedAirReduction.cpp | 131 +----- tests/CompressedAirLeakSurvey.unit.cpp | 94 ++++ tests/CompressedAirReduction.unit.cpp | 111 +---- tests/js/calculator.js | 410 ++++++++++-------- 10 files changed, 567 insertions(+), 848 deletions(-) create mode 100644 tests/CompressedAirLeakSurvey.unit.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cfa999ec..ab531068 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -412,6 +412,7 @@ set(TEST_FILES tests/ElectricityReduction.unit.cpp tests/NaturalGasReduction.unit.cpp tests/CompressedAirReduction.unit.cpp + tests/CompressedAirLeakSurvey.unit.cpp tests/CompressedAirPressureReduction.unit.cpp tests/WaterReduction.unit.cpp tests/InsulatedPipeReduction.unit.cpp diff --git a/bindings/calculator.cpp b/bindings/calculator.cpp index 4a9807b0..acc0b513 100644 --- a/bindings/calculator.cpp +++ b/bindings/calculator.cpp @@ -14,6 +14,9 @@ NAN_MODULE_INIT(InitCalculator) Nan::Set(target, New("compressedAirReduction").ToLocalChecked(), GetFunction(New(compressedAirReduction)).ToLocalChecked()); + Nan::Set(target, New("compressedAirLeakSurvey").ToLocalChecked(), + GetFunction(New(compressedAirLeakSurvey)).ToLocalChecked()); + Nan::Set(target, New("compressedAirPressureReduction").ToLocalChecked(), GetFunction(New(compressedAirPressureReduction)).ToLocalChecked()); diff --git a/bindings/calculator.h b/bindings/calculator.h index bfeffce5..860cb9b6 100644 --- a/bindings/calculator.h +++ b/bindings/calculator.h @@ -12,6 +12,7 @@ #include "calculator/util/ElectricityReduction.h" #include "calculator/util/NaturalGasReduction.h" #include "calculator/util/CompressedAirReduction.h" +#include "calculator/util/CompressedAirLeakSurvey.h" #include "calculator/util/CompressedAirPressureReduction.h" #include "calculator/util/WaterReduction.h" #include "calculator/util/insulation/pipes/InsulatedPipeInput.h" @@ -517,29 +518,114 @@ CompressedAirOtherMethodData getCompressedAirOtherMethodData(Local obj) return {consumption}; } -OrificeMethodData getOrificeMethodData(Local obj) +CompressorElectricityData getCompressorElectricityData(Local obj, bool convert = true) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::Local context = isolate->GetCurrentContext(); - Local getName = Nan::New("orificeMethodData").ToLocalChecked(); - Local orificeMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); - if (orificeMethodDataV8->IsUndefined()) + Local getName = Nan::New("compressorElectricityData").ToLocalChecked(); + Local compressorElectricityDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (compressorElectricityDataV8->IsUndefined()) { - ThrowTypeError(std::string("CompressedAirReduction: getOrificeMethodData method in calculator.h: orificeMethodData not present in object").c_str()); + ThrowTypeError(std::string("CompressedAirReduction: getCompressorElectricityData method in calculator.h: compressorElectricityData not present in object").c_str()); } - double airTemp = GetDouble("compressorAirTemp", orificeMethodDataV8); - double atmPressure = GetDouble("atmosphericPressure", orificeMethodDataV8); - double dischargeCoef = GetDouble("dischargeCoefficient", orificeMethodDataV8); - double diameter = GetDouble("orificeDiameter", orificeMethodDataV8); - double supplyPressure = GetDouble("supplyPressure", orificeMethodDataV8); - int numOrifices = static_cast(GetDouble("numberOfOrifices", orificeMethodDataV8)); + double compressorControlAdjustment; + if(convert) + { + compressorControlAdjustment = Conversion(GetDouble("compressorControlAdjustment", compressorElectricityDataV8)).percentToFraction(); + } + else + { + compressorControlAdjustment = GetDouble("compressorControlAdjustment", compressorElectricityDataV8); + } + double compressorSpecificPower = GetDouble("compressorSpecificPower", compressorElectricityDataV8); return { - airTemp, - atmPressure, - dischargeCoef, - diameter, - supplyPressure, - numOrifices}; + compressorControlAdjustment, + compressorSpecificPower}; +} + +CompressedAirReductionInput constructCompressedAirReductionInput(Local obj) +{ + int hoursPerYear = static_cast(GetDouble("hoursPerYear", obj)); + int utilityType = static_cast(GetDouble("utilityType", obj)); + double utilityCost = GetDouble("utilityCost", obj); + int measurementMethod = static_cast(GetDouble("measurementMethod", obj)); + CompressedAirFlowMeterMethodData airFlowData = getCompressedAirFlowMeterMethodData(obj); + BagMethodData bagMethodData = getBagMethodData(obj); + PressureMethodData pressureMethodData = getPressureMethodData(obj); + CompressedAirOtherMethodData otherMethodData = getCompressedAirOtherMethodData(obj); + CompressorElectricityData electricityData = getCompressorElectricityData(obj); + int units = static_cast(GetDouble("units", obj)); + return { + hoursPerYear, + utilityType, + utilityCost, + measurementMethod, + airFlowData, + bagMethodData, + pressureMethodData, + otherMethodData, + electricityData, + units}; +} + +std::vector getCompressedAirReductionInputVec() +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("compressedAirReductionInputVec").ToLocalChecked(); + Local arrayTmp = Nan::To(inp).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (arrayTmp->IsUndefined()) + { + ThrowTypeError(std::string("CompressedAirReduction: getCompressedAirReductionInputVec method in calculator.h: compressedAirReductionInputVec not present in object").c_str()); + } + Local compressedAirReductionInputArray = v8::Local::Cast(arrayTmp); + std::vector inputVec; + for (std::size_t i = 0; i < compressedAirReductionInputArray->Length(); i++) + { + inputVec.emplace_back(constructCompressedAirReductionInput(Nan::To(compressedAirReductionInputArray->Get(context, i).ToLocalChecked()).ToLocalChecked())); + } + return inputVec; +} + +NAN_METHOD(compressedAirReduction) +{ + inp = Nan::To(info[0]).ToLocalChecked(); + r = Nan::New(); + try + { + std::vector inputVec = getCompressedAirReductionInputVec(); + CompressedAirReduction::Output rv = CompressedAirReduction(inputVec).calculate(); + SetR("energyUse", rv.energyUse); + SetR("energyCost", rv.energyCost); + SetR("flowRate", rv.flowRate); + SetR("singleNozzleFlowRate", rv.singleNozzleFlowRate); + SetR("consumption", rv.consumption); + } + catch (std::runtime_error const &e) + { + std::string const what = e.what(); + ThrowError(std::string("std::runtime_error thrown in compressedAirReduction - calculator.h: " + what).c_str()); + } + info.GetReturnValue().Set(r); +} + +// ========== END Compressed Air ============== + +// ========== Start Air Leak Survey =========== + +EstimateMethodData getEstimateMethodData(Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("estimateMethodData").ToLocalChecked(); + Local estimateMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (estimateMethodDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CompressedAirReduction: getEstimateMethodData method in calculator.h: estimateMethodData not present in object").c_str()); + } + double leakRateEstimate = GetDouble("leakRateEstimate", estimateMethodDataV8); + return { + leakRateEstimate}; } DecibelsMethodData getDecibelsMethodData(Local obj) @@ -575,112 +661,97 @@ DecibelsMethodData getDecibelsMethodData(Local obj) secondFlowB}; } -EstimateMethodData getEstimateMethodData(Local obj) -{ - v8::Isolate *isolate = v8::Isolate::GetCurrent(); - v8::Local context = isolate->GetCurrentContext(); - Local getName = Nan::New("estimateMethodData").ToLocalChecked(); - Local estimateMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); - if (estimateMethodDataV8->IsUndefined()) - { - ThrowTypeError(std::string("CompressedAirReduction: getEstimateMethodData method in calculator.h: estimateMethodData not present in object").c_str()); - } - double leakRateEstimate = GetDouble("leakRateEstimate", estimateMethodDataV8); - return { - leakRateEstimate}; -} - -CompressorElectricityData getCompressorElectricityData(Local obj) +OrificeMethodData getOrificeMethodData(Local obj) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::Local context = isolate->GetCurrentContext(); - Local getName = Nan::New("compressorElectricityData").ToLocalChecked(); - Local compressorElectricityDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); - if (compressorElectricityDataV8->IsUndefined()) + Local getName = Nan::New("orificeMethodData").ToLocalChecked(); + Local orificeMethodDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (orificeMethodDataV8->IsUndefined()) { - ThrowTypeError(std::string("CompressedAirReduction: getCompressorElectricityData method in calculator.h: compressorElectricityData not present in object").c_str()); + ThrowTypeError(std::string("CompressedAirReduction: getOrificeMethodData method in calculator.h: orificeMethodData not present in object").c_str()); } - double compressorControlAdjustment = Conversion(GetDouble("compressorControlAdjustment", compressorElectricityDataV8)).percentToFraction(); - //double compressorControlAdjustment = GetDouble("compressorControlAdjustment", compressorElectricityDataV8); - double compressorSpecificPower = GetDouble("compressorSpecificPower", compressorElectricityDataV8); + double airTemp = GetDouble("compressorAirTemp", orificeMethodDataV8); + double atmPressure = GetDouble("atmosphericPressure", orificeMethodDataV8); + double dischargeCoef = GetDouble("dischargeCoefficient", orificeMethodDataV8); + double diameter = GetDouble("orificeDiameter", orificeMethodDataV8); + double supplyPressure = GetDouble("supplyPressure", orificeMethodDataV8); + int numOrifices = static_cast(GetDouble("numberOfOrifices", orificeMethodDataV8)); return { - compressorControlAdjustment, - compressorSpecificPower}; + airTemp, + atmPressure, + dischargeCoef, + diameter, + supplyPressure, + numOrifices}; } -CompressedAirReductionInput constructCompressedAirReductionInput(Local obj) +CompressedAirLeakSurveyInput constructCompressedAirLeakSurveyInput(Local obj) { int hoursPerYear = static_cast(GetDouble("hoursPerYear", obj)); int utilityType = static_cast(GetDouble("utilityType", obj)); double utilityCost = GetDouble("utilityCost", obj); int measurementMethod = static_cast(GetDouble("measurementMethod", obj)); - CompressedAirFlowMeterMethodData airFlowData = getCompressedAirFlowMeterMethodData(obj); + EstimateMethodData estimateMethodData = getEstimateMethodData(obj); + DecibelsMethodData decibelsMethodData = getDecibelsMethodData(obj); BagMethodData bagMethodData = getBagMethodData(obj); - PressureMethodData pressureMethodData = getPressureMethodData(obj); - CompressedAirOtherMethodData otherMethodData = getCompressedAirOtherMethodData(obj); OrificeMethodData orificeMethodData = getOrificeMethodData(obj); - DecibelsMethodData decibelsMethodData = getDecibelsMethodData(obj); - EstimateMethodData estimateMethodData = getEstimateMethodData(obj); - CompressorElectricityData electricityData = getCompressorElectricityData(obj); + CompressorElectricityData electricityData = getCompressorElectricityData(obj, false); int units = static_cast(GetDouble("units", obj)); return { hoursPerYear, utilityType, utilityCost, measurementMethod, - airFlowData, + estimateMethodData, + decibelsMethodData, bagMethodData, - pressureMethodData, - otherMethodData, orificeMethodData, - decibelsMethodData, - estimateMethodData, electricityData, units}; } -std::vector getCompressedAirReductionInputVec() +std::vector getCompressedAirLeakSurveyInputVec() { v8::Isolate *isolate = v8::Isolate::GetCurrent(); v8::Local context = isolate->GetCurrentContext(); - Local getName = Nan::New("compressedAirReductionInputVec").ToLocalChecked(); + Local getName = Nan::New("compressedAirLeakSurveyInputVec").ToLocalChecked(); Local arrayTmp = Nan::To(inp).ToLocalChecked()->Get(context, getName).ToLocalChecked(); if (arrayTmp->IsUndefined()) { - ThrowTypeError(std::string("CompressedAirReduction: getCompressedAirReductionInputVec method in calculator.h: compressedAirReductionInputVec not present in object").c_str()); + ThrowTypeError(std::string("CompressedAirLeakSurvey: getCompressedAirLeakSurveyInputVec method in calculator.h: compressedAirLeakSurveyInputVec not present in object").c_str()); } - Local compressedAirReductionInputArray = v8::Local::Cast(arrayTmp); - std::vector inputVec; - for (std::size_t i = 0; i < compressedAirReductionInputArray->Length(); i++) + Local compressedAirLeakSurveyInputArray = v8::Local::Cast(arrayTmp); + std::vector inputVec; + for (std::size_t i = 0; i < compressedAirLeakSurveyInputArray->Length(); i++) { - inputVec.emplace_back(constructCompressedAirReductionInput(Nan::To(compressedAirReductionInputArray->Get(context, i).ToLocalChecked()).ToLocalChecked())); + inputVec.emplace_back(constructCompressedAirLeakSurveyInput(Nan::To(compressedAirLeakSurveyInputArray->Get(context, i).ToLocalChecked()).ToLocalChecked())); } return inputVec; } -NAN_METHOD(compressedAirReduction) +NAN_METHOD(compressedAirLeakSurvey) { inp = Nan::To(info[0]).ToLocalChecked(); r = Nan::New(); try { - std::vector inputVec = getCompressedAirReductionInputVec(); - CompressedAirReduction::Output rv = CompressedAirReduction(inputVec).calculate(); + std::vector inputVec = getCompressedAirLeakSurveyInputVec(); + CompressedAirLeakSurvey::Output rv = CompressedAirLeakSurvey(inputVec).calculate(); SetR("energyUse", rv.energyUse); SetR("energyCost", rv.energyCost); SetR("flowRate", rv.flowRate); - SetR("singleNozzleFlowRate", rv.singleNozzleFlowRate); - SetR("consumption", rv.consumption); + SetR("compressedAirUse", rv.compressedAirUse); } catch (std::runtime_error const &e) { std::string const what = e.what(); - ThrowError(std::string("std::runtime_error thrown in compressedAirReduction - calculator.h: " + what).c_str()); + ThrowError(std::string("std::runtime_error thrown in compressedAirLeakSurvey - calculator.h: " + what).c_str()); } info.GetReturnValue().Set(r); } -// ========== END Compressed Air ============== +// ========== END Air Leak Survey ============= // ========== Start Water Reduction =========== diff --git a/include/calculator/util/CompressedAirLeakSurvey.h b/include/calculator/util/CompressedAirLeakSurvey.h index 5084a1d2..a761ad38 100644 --- a/include/calculator/util/CompressedAirLeakSurvey.h +++ b/include/calculator/util/CompressedAirLeakSurvey.h @@ -1,59 +1,21 @@ -/* #ifndef AMO_LIBRARY_COMPRESSEDAIRLEAKSURVEY_H #define AMO_LIBRARY_COMPRESSEDAIRLEAKSURVEY_H #include #include #include +#include "calculator/util/CompressedAirReduction.h" -class CompressedAirFlowMeterMethodData -{ - public: - CompressedAirFlowMeterMethodData(const double meterReading) - : meterReading(meterReading) {} - - double getMeterReading() const { return meterReading; } - void setMeterReading(double meterReading); - - private: - double meterReading; -}; - -class BagMethodData -{ - public: - BagMethodData(const double height, const double diameter, const double fillTime) - : height(height), diameter(diameter), fillTime(fillTime) {} - - double getHeight() const { return height; } - double getDiameter() const { return diameter; } - double getFillTime() const { return fillTime; } - void setHeight(double height); - void setDiameter(double diameter); - void setFillTime(double fillTime); - - private: - double height, diameter, fillTime; -}; - -class PressureMethodData +class EstimateMethodData { public: - PressureMethodData(const int nozzleType, const int numberOfNozzles, const double supplyPressure) - : nozzleType(nozzleType), numberOfNozzles(numberOfNozzles), supplyPressure(supplyPressure) {} - - int getNozzleType() const { return nozzleType; } - int getNumberOfNozzles() const { return numberOfNozzles; } - double getSupplyPressure() const { return supplyPressure; } - void setNozzleType(int nozzleType); - void setNumberOfNozzles(int numberOfNozzles); - void setSupplyPressure(double supplyPressure); + EstimateMethodData(const double leakRateEstimate) : leakRateEstimate(leakRateEstimate) {} - double calculate(); + double getLeakRateEstimate() const {return leakRateEstimate; } + void setLeakRateEstimate(double leakRateEstimate); private: - int nozzleType, numberOfNozzles; - double supplyPressure; + double leakRateEstimate; }; class DecibelsMethodData @@ -103,23 +65,13 @@ class DecibelsMethodData double secondFlowB; // Q22 }; -class EstimateMethodData -{ - public: - EstimateMethodData(const double leakRateEstimate) : leakRateEstimate(leakRateEstimate) {} - - double getLeakRateEstimate() const {return leakRateEstimate; } - void setLeakRateEstimate(double leakRateEstimate); - - private: - double leakRateEstimate; -}; +// BagMethodData implemented in CompressedAirReduction.h class OrificeMethodData { public: - OrificeMethodData(const double airTemp, const double atmPressure, const double dischargeCoef, // removed operatingTime - const double diameter, const double supplyPressure, const int numOrifices) + OrificeMethodData(const double airTemp, const double atmPressure, const double dischargeCoef, const double diameter, + const double supplyPressure, const int numOrifices) : airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), supplyPressure(supplyPressure), numOrifices(numOrifices) {} @@ -144,103 +96,66 @@ class OrificeMethodData int numOrifices; }; -class CompressedAirOtherMethodData +class CompressedAirLeakSurveyInput { public: - CompressedAirOtherMethodData(const double consumption) - : consumption(consumption) {} - - double getConsumption() const { return consumption; } - void setConsumption(double consumption); - - private: - double consumption; -}; - -//calculates electricity use for a compressor if utilityType == electricity -class CompressorElectricityData -{ - public: - CompressorElectricityData(const double compressorControlAdjustment, const double compressorSpecificPower) - : compressorControlAdjustment(compressorControlAdjustment), compressorSpecificPower(compressorSpecificPower) {} - - double calculate(); - - private: - double compressorControlAdjustment, compressorSpecificPower; -}; - -class CompressedAirReductionInput -{ - public: - CompressedAirReductionInput(const int hoursPerYear, const int utilityType, const double utilityCost, const int measurementMethod, - const CompressedAirFlowMeterMethodData flowMeterMethodData, const BagMethodData bagMethodData, - const PressureMethodData pressureMethodData, const CompressedAirOtherMethodData otherMethodData, - const OrificeMethodData orificeMethodData, const DecibelsMethodData decibelsMethodData, - const EstimateMethodData estimateMethodData, const CompressorElectricityData compressorElectricityData, - const int units) + CompressedAirLeakSurveyInput(const int hoursPerYear, const int utilityType, const double utilityCost, const int measurementMethod, + const EstimateMethodData estimateMethodData, const DecibelsMethodData decibelsMethodData, + const BagMethodData bagMethodData, const OrificeMethodData orificeMethodData, + const CompressorElectricityData compressorElectricityData, const int units) : hoursPerYear(hoursPerYear), utilityType(utilityType), utilityCost(utilityCost), measurementMethod(measurementMethod), - flowMeterMethodData(flowMeterMethodData), bagMethodData(bagMethodData), - pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), orificeMethodData(orificeMethodData), - decibelsMethodData(decibelsMethodData), estimateMethodData(estimateMethodData), - compressorElectricityData(compressorElectricityData), units(units) {} + estimateMethodData(estimateMethodData), decibelsMethodData(decibelsMethodData), bagMethodData(bagMethodData), + orificeMethodData(orificeMethodData), compressorElectricityData(compressorElectricityData), units(units) {} int getHoursPerYear() const { return hoursPerYear; } // operating time int getUtilityType() const { return utilityType; } int getMeasurementMethod() const { return measurementMethod; } int getUnits() const { return units; } double getUtilityCost() const { return utilityCost; } - CompressedAirFlowMeterMethodData getFlowMeterMethodData() const { return flowMeterMethodData; } + EstimateMethodData getEstimateMethodData() const { return estimateMethodData; } + DecibelsMethodData getDecibelsMethodData() const { return decibelsMethodData; } BagMethodData getBagMethodData() const { return bagMethodData; } - PressureMethodData getPressureMethodData() const { return pressureMethodData; } - CompressedAirOtherMethodData getOtherMethodData() const { return otherMethodData; } OrificeMethodData getOrificeMethodData() const { return orificeMethodData; } - DecibelsMethodData getDecibelsMethodData() const { return decibelsMethodData; } - EstimateMethodData getEstimateMethodData() const { return estimateMethodData; } CompressorElectricityData getCompressorElectricityData() const { return compressorElectricityData; } private: int hoursPerYear, utilityType; double utilityCost; int measurementMethod; - CompressedAirFlowMeterMethodData flowMeterMethodData; + EstimateMethodData estimateMethodData; + DecibelsMethodData decibelsMethodData; BagMethodData bagMethodData; - PressureMethodData pressureMethodData; - CompressedAirOtherMethodData otherMethodData; OrificeMethodData orificeMethodData; - DecibelsMethodData decibelsMethodData; - EstimateMethodData estimateMethodData; CompressorElectricityData compressorElectricityData; int units; }; -class CompressedAirReduction +class CompressedAirLeakSurvey { public: struct Output { - Output(double energyUse, double energyCost, double flowRate, double singleNozzleFlowRate, double consumption) - : energyUse(energyUse), energyCost(energyCost), flowRate(flowRate), singleNozzleFlowRate(singleNozzleFlowRate), consumption(consumption) {} + Output(double energyUse, double energyCost, double flowRate, double compressedAirUse) + : energyUse(energyUse), energyCost(energyCost), flowRate(flowRate), compressedAirUse(compressedAirUse) {} Output() = default; - double energyUse = 0, energyCost = 0, flowRate = 0, singleNozzleFlowRate, consumption = 0; + double energyUse = 0, energyCost = 0, flowRate = 0, compressedAirUse = 0; }; - CompressedAirReduction(std::vector &compressedAirReductionInputVec) : compressedAirReductionInputVec(compressedAirReductionInputVec) + CompressedAirLeakSurvey(std::vector &compressedAirLeakSurveyInputVec) : compressedAirLeakSurveyInputVec(compressedAirLeakSurveyInputVec) { } - CompressedAirReduction::Output calculate(); - std::vector const &getCompressedAirReductionInputVec() const + CompressedAirLeakSurvey::Output calculate(); + std::vector const &getCompressedAirLeakSurveyInputVec() const { - return compressedAirReductionInputVec; + return compressedAirLeakSurveyInputVec; } void setCompressedAirReductionInputVec(std::vector &compressedAirReductionInputVec); private: - std::vector compressedAirReductionInputVec; - CompressedAirReduction::Output output; + std::vector compressedAirLeakSurveyInputVec; + CompressedAirLeakSurvey::Output output; }; -#endif // AMO_LIBRARY_COMPRESSEDAIRLeakSurvey_H -*/ \ No newline at end of file +#endif // AMO_LIBRARY_COMPRESSEDAIRLEAKSURVEY_H \ No newline at end of file diff --git a/include/calculator/util/CompressedAirReduction.h b/include/calculator/util/CompressedAirReduction.h index 242cd85d..aaceb057 100644 --- a/include/calculator/util/CompressedAirReduction.h +++ b/include/calculator/util/CompressedAirReduction.h @@ -55,94 +55,6 @@ class PressureMethodData double supplyPressure; }; -class DecibelsMethodData -{ - public: - DecibelsMethodData(const double linePressure, const double decibels, const double decibelRatingA, - const double pressureA, const double firstFlowA, const double secondFlowA, const double decibelRatingB, const double pressureB, - const double firstFlowB, const double secondFlowB) - : linePressure(linePressure), decibels(decibels), decibelRatingA(decibelRatingA), - pressureA(pressureA), firstFlowA(firstFlowA), secondFlowA(secondFlowA), decibelRatingB(decibelRatingB), - pressureB(pressureB), firstFlowB(firstFlowB), secondFlowB(secondFlowB) {} - - double getLinePressure() const { return linePressure; } - double getDecibels() const { return decibels; } - double getDecibelRatingA() const { return decibelRatingA; } - double getPressureA() const { return pressureA; } - double getFirstFlowA() const { return firstFlowA; } - double getSecondFlowA() const { return secondFlowA; } - double getDecibelRatingB() const { return decibelRatingB; } - double getPressureB() const { return pressureB; } - double getFirstFlowB() const { return firstFlowB; } - double getSecondFlowB() const { return secondFlowB; } - - void setLinePressure(double linePressure); - void setDecibels(double decibels); - void setDecibelRatingA(double decibelRatingA); - void setPressureA(double pressureA); - void setFirstFlowA(double firstFlowA); - void setSecondFlowA(double secondFlowA); - void setDecibelRatingB(double decibelRatingB); - void setPressureB(double pressureB); - void setFirstFlowB(double firstFlowB); - void setSecondFlowB(double secondFlowB); - - double calculate(); - - private: - double linePressure; // X - double decibels; // Y - double decibelRatingA; // Y1 - double pressureA; // X1 - double firstFlowA; // Q11 - double secondFlowA; // Q21 - double decibelRatingB; // Y2 - double pressureB; // X2 - double firstFlowB; // Q12 - double secondFlowB; // Q22 -}; - -class EstimateMethodData -{ - public: - EstimateMethodData(const double leakRateEstimate) : leakRateEstimate(leakRateEstimate) {} - - double getLeakRateEstimate() const {return leakRateEstimate; } - void setLeakRateEstimate(double leakRateEstimate); - - private: - double leakRateEstimate; -}; - -class OrificeMethodData -{ - public: - OrificeMethodData(const double airTemp, const double atmPressure, const double dischargeCoef, // removed operatingTime - const double diameter, const double supplyPressure, const int numOrifices) - : airTemp(airTemp), atmPressure(atmPressure), dischargeCoef(dischargeCoef), diameter(diameter), - supplyPressure(supplyPressure), numOrifices(numOrifices) {} - - double getAirTemp() const { return airTemp; } - double getAtmPressure() const { return atmPressure; } - double getDischargeCoef() const { return dischargeCoef; } - double getDiameter() const { return diameter; } - double getSupplyPressure() const { return supplyPressure; } - int getNumOrifices() const { return numOrifices; } - - void setAirTemp(double airTemp); - void setAtmPressure(double atmPressure); - void setDischargeCoef(double dischargeCoef); - void setDiameter(double diameter); - void setSupplyPressure(double supplyPressure); - void setNumOrifices(int numOrifices); - - double calculate(); - - private: - double airTemp, atmPressure, dischargeCoef, diameter, supplyPressure; - int numOrifices; -}; - class CompressedAirOtherMethodData { public: @@ -175,16 +87,13 @@ class CompressedAirReductionInput CompressedAirReductionInput(const int hoursPerYear, const int utilityType, const double utilityCost, const int measurementMethod, const CompressedAirFlowMeterMethodData flowMeterMethodData, const BagMethodData bagMethodData, const PressureMethodData pressureMethodData, const CompressedAirOtherMethodData otherMethodData, - const OrificeMethodData orificeMethodData, const DecibelsMethodData decibelsMethodData, - const EstimateMethodData estimateMethodData, const CompressorElectricityData compressorElectricityData, - const int units) + const CompressorElectricityData compressorElectricityData, const int units) : hoursPerYear(hoursPerYear), utilityType(utilityType), utilityCost(utilityCost), measurementMethod(measurementMethod), flowMeterMethodData(flowMeterMethodData), bagMethodData(bagMethodData), - pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), orificeMethodData(orificeMethodData), - decibelsMethodData(decibelsMethodData), estimateMethodData(estimateMethodData), + pressureMethodData(pressureMethodData), otherMethodData(otherMethodData), compressorElectricityData(compressorElectricityData), units(units) {} - int getHoursPerYear() const { return hoursPerYear; } // operating time + int getHoursPerYear() const { return hoursPerYear; } int getUtilityType() const { return utilityType; } int getMeasurementMethod() const { return measurementMethod; } int getUnits() const { return units; } @@ -193,9 +102,6 @@ class CompressedAirReductionInput BagMethodData getBagMethodData() const { return bagMethodData; } PressureMethodData getPressureMethodData() const { return pressureMethodData; } CompressedAirOtherMethodData getOtherMethodData() const { return otherMethodData; } - OrificeMethodData getOrificeMethodData() const { return orificeMethodData; } - DecibelsMethodData getDecibelsMethodData() const { return decibelsMethodData; } - EstimateMethodData getEstimateMethodData() const { return estimateMethodData; } CompressorElectricityData getCompressorElectricityData() const { return compressorElectricityData; } private: @@ -206,9 +112,6 @@ class CompressedAirReductionInput BagMethodData bagMethodData; PressureMethodData pressureMethodData; CompressedAirOtherMethodData otherMethodData; - OrificeMethodData orificeMethodData; - DecibelsMethodData decibelsMethodData; - EstimateMethodData estimateMethodData; CompressorElectricityData compressorElectricityData; int units; }; diff --git a/src/calculator/util/CompressedAirLeakSurvey.cpp b/src/calculator/util/CompressedAirLeakSurvey.cpp index 791b6622..119d806e 100644 --- a/src/calculator/util/CompressedAirLeakSurvey.cpp +++ b/src/calculator/util/CompressedAirLeakSurvey.cpp @@ -1,4 +1,3 @@ -/* #include #include #include "calculator/util/CompressedAirLeakSurvey.h" @@ -6,109 +5,63 @@ #define M_PI 3.14159265358979323846 #endif -CompressedAirReduction::Output CompressedAirReduction::calculate() +CompressedAirLeakSurvey::Output CompressedAirLeakSurvey::calculate() { - double totalEnergyUse = 0, totalEnergyCost = 0, totalFlowRate = 0, singleNozzleFlowRate = 0, totalConsumption = 0; + double totalEnergyUse = 0, totalEnergyCost = 0, totalFlowRate = 0, totalCompressedAirUse = 0; - for (auto &compressedAirReductionInput : compressedAirReductionInputVec) + for (auto &compressedAirLeakSurveyInput : compressedAirLeakSurveyInputVec) { - double tmpEnergyUse = 0, tmpEnergyCost = 0, tmpFlowRate = 0, tmpSingleNozzleFlowRate = 0, tmpTotalConsumption = 0; + double tmpEnergyUse = 0, tmpEnergyCost = 0, tmpFlowRate = 0, tmpSingleNozzleFlowRate = 0, tmpTotalCompressedAirUse = 0; - // compressed air flow meter - if (compressedAirReductionInput.getMeasurementMethod() == 0) - { - CompressedAirFlowMeterMethodData flowMeterMethodData = compressedAirReductionInput.getFlowMeterMethodData(); - tmpTotalConsumption = flowMeterMethodData.getMeterReading() * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); - tmpFlowRate = flowMeterMethodData.getMeterReading(); - } - // bag method - else if (compressedAirReductionInput.getMeasurementMethod() == 1) + // estimate method + if(compressedAirLeakSurveyInput.getMeasurementMethod() == 0) { - BagMethodData bagMethodData = compressedAirReductionInput.getBagMethodData(); - tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); - tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); + EstimateMethodData estimateMethodData = compressedAirLeakSurveyInput.getEstimateMethodData(); + tmpFlowRate = estimateMethodData.getLeakRateEstimate(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); } - // pressure method - else if (compressedAirReductionInput.getMeasurementMethod() == 2) + // decibels method + else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 1) { - PressureMethodData pressureMethodData = compressedAirReductionInput.getPressureMethodData(); - tmpSingleNozzleFlowRate = pressureMethodData.calculate(); - tmpFlowRate = tmpSingleNozzleFlowRate * pressureMethodData.getNumberOfNozzles(); - tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear(); + DecibelsMethodData decibelsMethodData = compressedAirLeakSurveyInput.getDecibelsMethodData(); + tmpFlowRate = decibelsMethodData.calculate(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); } - // other method - else if (compressedAirReductionInput.getMeasurementMethod() == 3) + // bag method + else if (compressedAirLeakSurveyInput.getMeasurementMethod() == 2) { - CompressedAirOtherMethodData otherMethodData = compressedAirReductionInput.getOtherMethodData(); - tmpTotalConsumption = otherMethodData.getConsumption(); + BagMethodData bagMethodData = compressedAirLeakSurveyInput.getBagMethodData(); + tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); + tmpTotalCompressedAirUse = tmpFlowRate * 60.0 * compressedAirLeakSurveyInput.getHoursPerYear() * compressedAirLeakSurveyInput.getUnits(); } // orifice method - else if(compressedAirReductionInput.getMeasurementMethod() == 4) + else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 3) { - OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); + OrificeMethodData orificeMethodData = compressedAirLeakSurveyInput.getOrificeMethodData(); tmpFlowRate = orificeMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); - } - // decibels method - else if(compressedAirReductionInput.getMeasurementMethod() == 5) - { - DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); - tmpFlowRate = decibelsMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); - } - // estimate method - else if(compressedAirReductionInput.getMeasurementMethod() == 6) - { - EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); - tmpFlowRate = estimateMethodData.getLeakRateEstimate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); } //electricity calculation - if (compressedAirReductionInput.getUtilityType() == 0) + if (compressedAirLeakSurveyInput.getUtilityType() == 0) { - tmpEnergyCost = compressedAirReductionInput.getUtilityCost() * tmpTotalConsumption; + tmpEnergyCost = compressedAirLeakSurveyInput.getUtilityCost() * tmpTotalCompressedAirUse; } - else if (compressedAirReductionInput.getUtilityType() == 1) + else if (compressedAirLeakSurveyInput.getUtilityType() == 1) { - CompressorElectricityData compressorElectricityData = compressedAirReductionInput.getCompressorElectricityData(); + CompressorElectricityData compressorElectricityData = compressedAirLeakSurveyInput.getCompressorElectricityData(); double electricityCalculation = compressorElectricityData.calculate(); - tmpEnergyUse = electricityCalculation * tmpTotalConsumption; - tmpEnergyCost = tmpEnergyUse * compressedAirReductionInput.getUtilityCost(); + tmpEnergyUse = electricityCalculation * tmpTotalCompressedAirUse; + tmpEnergyCost = tmpEnergyUse * compressedAirLeakSurveyInput.getUtilityCost(); } totalEnergyUse += tmpEnergyUse; totalEnergyCost += tmpEnergyCost; totalFlowRate += tmpFlowRate; - singleNozzleFlowRate += tmpSingleNozzleFlowRate; - totalConsumption += tmpTotalConsumption; + totalCompressedAirUse += tmpTotalCompressedAirUse; } - return CompressedAirReduction::Output(totalEnergyUse, totalEnergyCost, totalFlowRate, singleNozzleFlowRate, totalConsumption); -} - -double PressureMethodData::calculate() -{ - static double nozzleTable[13][3] = { - {-2.2e-07, 0.018893, 0.268476}, - {-2.8e-05, 0.038377, 1.061905}, - {-7.6e-05, 1.537424, 14.3}, - {-2.2e-05, 0.345931, 5.780952}, - {0.000682, 0.643182, 13.83333}, - {5.41e-06, 0.228851, 2.968095}, - {-2.1e-06, 0.075463, 1.089857}, - {-2.8e-05, 0.14871, 1.841905}, - {0.002652, 2.250152, 46.56667}, - {0.000747, 0.842056, 15.95714}, - {0.000411, 0.560649, 10.1619}, - {0.000935, 0.130792, 4.429524}, - {0.000935, 0.130792, 4.429524}}; - - const double a = nozzleTable[this->nozzleType][0]; - const double b = nozzleTable[this->nozzleType][1]; - const double c = nozzleTable[this->nozzleType][2]; - double singleNozzleFlowRate = (a * (pow(this->supplyPressure, 2.0))) + (b * this->supplyPressure) + c; - return singleNozzleFlowRate; + return CompressedAirLeakSurvey::Output(totalEnergyUse, totalEnergyCost, totalFlowRate, totalCompressedAirUse); } double DecibelsMethodData::calculate() @@ -135,6 +88,8 @@ double DecibelsMethodData::calculate() return leakRateEstimate; } +// BagMathodData::calculate() implemented in CompressedAirReduction.cpp + double OrificeMethodData::calculate() { const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); @@ -143,80 +98,13 @@ double OrificeMethodData::calculate() const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; const double leakRateScfm = leakRateLBMmin / standardDensity; const double leakRateEstimate = leakRateScfm * numOrifices; - //const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; return leakRateEstimate; } -double CompressorElectricityData::calculate() -{ - const double c = 1.0 / 60; - return c * this->compressorControlAdjustment * this->compressorSpecificPower; -} - -void CompressedAirReduction::setCompressedAirReductionInputVec(std::vector &compressedAirReductionInputVec) -{ - this->compressedAirReductionInputVec = std::move(compressedAirReductionInputVec); -} - -void CompressedAirOtherMethodData::setConsumption(const double consumption) -{ - this->consumption = consumption; -} - -void PressureMethodData::setNozzleType(const int nozzleType) -{ - this->nozzleType = nozzleType; -} - -void PressureMethodData::setNumberOfNozzles(const int numberOfNozzles) -{ - this->numberOfNozzles = numberOfNozzles; -} - -void PressureMethodData::setSupplyPressure(const double supplyPressure) -{ - this->supplyPressure = supplyPressure; -} - -void BagMethodData::setHeight(const double height) -{ - this->height = height; -} - -void BagMethodData::setDiameter(const double diameter) -{ - this->diameter = diameter; -} - -void BagMethodData::setFillTime(const double fillTime) -{ - this->fillTime = fillTime; -} - -void OrificeMethodData::setAirTemp(const double airTemp) -{ - this->airTemp = airTemp; -} -void OrificeMethodData::setAtmPressure(const double atmPressure) -{ - this->atmPressure = atmPressure; -} -void OrificeMethodData::setDischargeCoef(const double dischargeCoef) -{ - this->dischargeCoef = dischargeCoef; -} -void OrificeMethodData::setDiameter(const double diameter) -{ - this->diameter = diameter; -} -void OrificeMethodData::setSupplyPressure(const double supplyPressure) -{ - this->supplyPressure = supplyPressure; -} -void OrificeMethodData::setNumOrifices(const int numOrifices) +void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) { - this->numOrifices = numOrifices; + this->leakRateEstimate = leakRateEstimate; } void DecibelsMethodData::setLinePressure(double linePressure) @@ -260,13 +148,29 @@ void DecibelsMethodData::setSecondFlowB(double secondFlowB) this->secondFlowB = secondFlowB; } -void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) +// BagMethodData methods implemented in CompressedAirReduction.cpp + +void OrificeMethodData::setAirTemp(const double airTemp) { - this->leakRateEstimate = leakRateEstimate; + this->airTemp = airTemp; } - -void CompressedAirFlowMeterMethodData::setMeterReading(const double meterReading) +void OrificeMethodData::setAtmPressure(const double atmPressure) +{ + this->atmPressure = atmPressure; +} +void OrificeMethodData::setDischargeCoef(const double dischargeCoef) { - this->meterReading = meterReading; + this->dischargeCoef = dischargeCoef; +} +void OrificeMethodData::setDiameter(const double diameter) +{ + this->diameter = diameter; +} +void OrificeMethodData::setSupplyPressure(const double supplyPressure) +{ + this->supplyPressure = supplyPressure; } -*/ \ No newline at end of file +void OrificeMethodData::setNumOrifices(const int numOrifices) +{ + this->numOrifices = numOrifices; +} \ No newline at end of file diff --git a/src/calculator/util/CompressedAirReduction.cpp b/src/calculator/util/CompressedAirReduction.cpp index 0a826de3..e0d1a3d7 100644 --- a/src/calculator/util/CompressedAirReduction.cpp +++ b/src/calculator/util/CompressedAirReduction.cpp @@ -27,7 +27,7 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); tmpTotalConsumption = tmpFlowRate * 60.0 * compressedAirReductionInput.getHoursPerYear() * compressedAirReductionInput.getUnits(); } - // pressure method + // orifice/pressure method else if (compressedAirReductionInput.getMeasurementMethod() == 2) { PressureMethodData pressureMethodData = compressedAirReductionInput.getPressureMethodData(); @@ -41,27 +41,6 @@ CompressedAirReduction::Output CompressedAirReduction::calculate() CompressedAirOtherMethodData otherMethodData = compressedAirReductionInput.getOtherMethodData(); tmpTotalConsumption = otherMethodData.getConsumption(); } - // orifice method - else if(compressedAirReductionInput.getMeasurementMethod() == 4) - { - OrificeMethodData orificeMethodData = compressedAirReductionInput.getOrificeMethodData(); - tmpFlowRate = orificeMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); - } - // decibels method - else if(compressedAirReductionInput.getMeasurementMethod() == 5) - { - DecibelsMethodData decibelsMethodData = compressedAirReductionInput.getDecibelsMethodData(); - tmpFlowRate = decibelsMethodData.calculate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); - } - // estimate method - else if(compressedAirReductionInput.getMeasurementMethod() == 6) - { - EstimateMethodData estimateMethodData = compressedAirReductionInput.getEstimateMethodData(); - tmpFlowRate = estimateMethodData.getLeakRateEstimate(); - tmpTotalConsumption = (compressedAirReductionInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirReductionInput.getUnits(); - } //electricity calculation if (compressedAirReductionInput.getUtilityType() == 0) @@ -110,43 +89,6 @@ double PressureMethodData::calculate() return singleNozzleFlowRate; } -double DecibelsMethodData::calculate() -{ - /* - double linePressure; // X - double decibels; // Y - double decibelRatingA; // Y1 - double pressureA; // X1 - double firstFlowA; // Q11 - double secondFlowA; // Q21 - double decibelRatingB; // Y2 - double pressureB; // X2 - double firstFlowB; // Q12 - double secondFlowB; // Q22 - */ - - const double denominator = (pressureB - pressureA) * (decibelRatingB - decibelRatingA); - const double leakRateEstimate = ((pressureB - linePressure) * (decibelRatingB - decibels)) / denominator * firstFlowA - + ((linePressure - pressureA) * (decibelRatingB - decibels)) / denominator * secondFlowA - + ((pressureB - linePressure) * (decibels - decibelRatingA)) / denominator * firstFlowB - + ((linePressure - pressureA) * (decibels - decibelRatingA)) / denominator * secondFlowB; - - return leakRateEstimate; -} - -double OrificeMethodData::calculate() -{ - const double standardDensity = (atmPressure + supplyPressure) * (144 / (53.34 * airTemp)); - const double sonicDensity = std::pow(standardDensity * (2 / (1.4 + 1)), 1/(1.4 - 1)); - const double leakVelocity = std::pow(((2 * 1.4) / (1.4 + 1)) * 53.34 * airTemp * 32.2, 0.5); - const double leakRateLBMmin = sonicDensity * (diameter * diameter) * (M_PI/(4 * 144)) * leakVelocity * 60 * dischargeCoef; - const double leakRateScfm = leakRateLBMmin / standardDensity; - const double leakRateEstimate = leakRateScfm * numOrifices; - //const double annualComsumption = (operatingTime * leakRateEstimate * 60) / 1000; - - return leakRateEstimate; -} - double CompressorElectricityData::calculate() { const double c = 1.0 / 60; @@ -193,77 +135,6 @@ void BagMethodData::setFillTime(const double fillTime) this->fillTime = fillTime; } -void OrificeMethodData::setAirTemp(const double airTemp) -{ - this->airTemp = airTemp; -} -void OrificeMethodData::setAtmPressure(const double atmPressure) -{ - this->atmPressure = atmPressure; -} -void OrificeMethodData::setDischargeCoef(const double dischargeCoef) -{ - this->dischargeCoef = dischargeCoef; -} -void OrificeMethodData::setDiameter(const double diameter) -{ - this->diameter = diameter; -} -void OrificeMethodData::setSupplyPressure(const double supplyPressure) -{ - this->supplyPressure = supplyPressure; -} -void OrificeMethodData::setNumOrifices(const int numOrifices) -{ - this->numOrifices = numOrifices; -} - -void DecibelsMethodData::setLinePressure(double linePressure) -{ - this->linePressure = linePressure; -} -void DecibelsMethodData::setDecibels(double decibels) -{ - this->decibels = decibels; -} -void DecibelsMethodData::setDecibelRatingA(double decibelRatingA) -{ - this->decibelRatingA = decibelRatingA; -} -void DecibelsMethodData::setPressureA(double pressureA) -{ - this->pressureA = pressureA; -} -void DecibelsMethodData::setFirstFlowA(double firstFlowA) -{ - this->firstFlowA = firstFlowA; -} -void DecibelsMethodData::setSecondFlowA(double secondFlowA) -{ - this->secondFlowA = secondFlowA; -} -void DecibelsMethodData::setDecibelRatingB(double decibelRatingB) -{ - this->decibelRatingB = decibelRatingB; -} -void DecibelsMethodData::setPressureB(double pressureB) -{ - this->pressureB = pressureB; -} -void DecibelsMethodData::setFirstFlowB(double firstFlowB) -{ - this->firstFlowB = firstFlowB; -} -void DecibelsMethodData::setSecondFlowB(double secondFlowB) -{ - this->secondFlowB = secondFlowB; -} - -void EstimateMethodData::setLeakRateEstimate(const double leakRateEstimate) -{ - this->leakRateEstimate = leakRateEstimate; -} - void CompressedAirFlowMeterMethodData::setMeterReading(const double meterReading) { this->meterReading = meterReading; diff --git a/tests/CompressedAirLeakSurvey.unit.cpp b/tests/CompressedAirLeakSurvey.unit.cpp new file mode 100644 index 00000000..4ebd01f3 --- /dev/null +++ b/tests/CompressedAirLeakSurvey.unit.cpp @@ -0,0 +1,94 @@ +#include +#include "calculator/util/CompressedAirLeakSurvey.h" + +TEST_CASE("Compressed Air Leak Survey Estimate Method and Electricity", "[CompressedAirLeakSurvey][Util]") +{ + std::vector compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(8640, 1, 0.12, 0, + EstimateMethodData(0.1), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + auto testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(55.296)); + CHECK(testOutput.energyCost == Approx(6.63552)); + CHECK(testOutput.flowRate == Approx(0.1)); + CHECK(testOutput.compressedAirUse == Approx(51840)); + + compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(3840, 1, 0.12, 0, + EstimateMethodData(0.1), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.25, 0.16), + 1)}; + + compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(15.36)); + CHECK(testOutput.energyCost == Approx(1.8432)); + CHECK(testOutput.flowRate == Approx(0.1)); + CHECK(testOutput.compressedAirUse == Approx(23040)); +} + +TEST_CASE("Compressed Air Leak Survey Decibels Method and Electricity", "[CompressedAirLeakSurvey][Util]") +{ + std::vector compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(8640, 1, 0.12, 1, + EstimateMethodData(0.1), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + auto testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(790.17984)); + CHECK(testOutput.energyCost == Approx(94.8215808)); + CHECK(testOutput.flowRate == Approx(1.429)); + CHECK(testOutput.compressedAirUse == Approx(740793.6)); +} + +TEST_CASE("Compressed Air Leak Survey Bag Method and Electricity", "[CompressedAirLeakSurvey][Util]") +{ + std::vector compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(8640, 1, 0.12, 2, + EstimateMethodData(0.1), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.40, 0.16), + 2)}; + + auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + auto testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(3769.9111)); + CHECK(testOutput.energyCost == Approx(452.3893)); + CHECK(testOutput.flowRate == Approx(3.408846)); + CHECK(testOutput.compressedAirUse == Approx(3534291.73528)); +} + +TEST_CASE("Compressed Air Leak Survey Orifice Method and Electricity", "[CompressedAirLeakSurvey][Util]") +{ + std::vector compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(8640, 1, 0.12, 3, + EstimateMethodData(0.1), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.40, 0.16), + 1)}; + + auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + auto testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(1253583.3379004421)); + CHECK(testOutput.energyCost == Approx(150430.000548053)); + CHECK(testOutput.flowRate == Approx(2267.0416267007)); + CHECK(testOutput.compressedAirUse == Approx(1175234379)); +} \ No newline at end of file diff --git a/tests/CompressedAirReduction.unit.cpp b/tests/CompressedAirReduction.unit.cpp index 70b39340..ef8e448e 100644 --- a/tests/CompressedAirReduction.unit.cpp +++ b/tests/CompressedAirReduction.unit.cpp @@ -9,9 +9,6 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method", "[CompressedAirReduction BagMethodData(10, 5, 30), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(1.428, 1.38233), 1)}; @@ -32,9 +29,6 @@ TEST_CASE("Compressed Air Reduction Flow Meter Method and Electricity", "[Compre BagMethodData(10, 5, 30), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(0.8, 0.16), 1)}; @@ -55,9 +49,6 @@ TEST_CASE("Compressed Air Reduction Bag Method and Electricity", "[CompressedAir BagMethodData(15, 10, 12), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 2)}; @@ -70,7 +61,7 @@ TEST_CASE("Compressed Air Reduction Bag Method and Electricity", "[CompressedAir CHECK(testOutput.consumption == Approx(3534291.73528)); } -TEST_CASE("Compressed Air Reduction Pressure Method and Electricity", "[CompressedAirReduction][Util]") +TEST_CASE("Compressed Air Reduction Orifice Pressure Method and Electricity", "[CompressedAirReduction][Util]") { std::vector compressedAirReductionInputVec = { CompressedAirReductionInput(8640, 1, 0.12, 2, @@ -78,9 +69,6 @@ TEST_CASE("Compressed Air Reduction Pressure Method and Electricity", "[Compress BagMethodData(15, 10, 12), PressureMethodData(0, 1, 80), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; @@ -93,7 +81,7 @@ TEST_CASE("Compressed Air Reduction Pressure Method and Electricity", "[Compress CHECK(testOutput.consumption == Approx(921978.5471999)); } -TEST_CASE("Compressed Air Reduction Pressure Method Multiple Nozzles", "[CompressedAirReduction][Util]") +TEST_CASE("Compressed Air Reduction Orifice Pressure Method Multiple Nozzles", "[CompressedAirReduction][Util]") { std::vector compressedAirReductionInputVec = { CompressedAirReductionInput(8640, 1, 0.12, 2, @@ -101,9 +89,6 @@ TEST_CASE("Compressed Air Reduction Pressure Method Multiple Nozzles", "[Compres BagMethodData(15, 10, 12), PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 3)}; @@ -124,9 +109,6 @@ TEST_CASE("Compressed Air Reduction Other Method", "[CompressedAirReduction][Uti BagMethodData(15, 10, 12), PressureMethodData(2, 4, 50), CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), CompressorElectricityData(0.40, 0.16), 1)}; @@ -135,93 +117,4 @@ TEST_CASE("Compressed Air Reduction Other Method", "[CompressedAirReduction][Uti CHECK(testOutput.consumption == Approx(200000.00)); CHECK(testOutput.energyUse == Approx(213.3333)); CHECK(testOutput.energyCost == Approx(25.6)); -} - -TEST_CASE("Compressed Air Reduction Orifice Method and Electricity", "[CompressedAirReduction][Util]") -{ - std::vector compressedAirReductionInputVec = { - CompressedAirReductionInput(8640, 1, 0.12, 4, - CompressedAirFlowMeterMethodData(200000), - BagMethodData(15, 10, 12), - PressureMethodData(0, 1, 80), - CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), - CompressorElectricityData(0.40, 0.16), - 1)}; - - auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); - auto testOutput = compressedAirReduction.calculate(); - CHECK(testOutput.energyUse == Approx(1253583.3379004421)); - CHECK(testOutput.energyCost == Approx(150430.000548053)); - CHECK(testOutput.flowRate == Approx(2267.0416267007)); - CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); - CHECK(testOutput.consumption == Approx(1175234379)); -} - -TEST_CASE("Compressed Air Reduction Decibels Method and Electricity", "[CompressedAirReduction][Util]") -{ - std::vector compressedAirReductionInputVec = { - CompressedAirReductionInput(8640, 1, 0.12, 5, - CompressedAirFlowMeterMethodData(200000), - BagMethodData(15, 10, 12), - PressureMethodData(0, 1, 80), - CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), - CompressorElectricityData(0.40, 0.16), - 1)}; - - auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); - auto testOutput = compressedAirReduction.calculate(); - CHECK(testOutput.energyUse == Approx(790.17984)); - CHECK(testOutput.energyCost == Approx(94.8215808)); - CHECK(testOutput.flowRate == Approx(1.429)); - CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); - CHECK(testOutput.consumption == Approx(740793.6)); -} - -TEST_CASE("Compressed Air Reduction Estimate Method and Electricity", "[CompressedAirReduction][Util]") -{ - std::vector compressedAirReductionInputVec = { - CompressedAirReductionInput(8640, 1, 0.12, 6, - CompressedAirFlowMeterMethodData(200000), - BagMethodData(15, 10, 12), - PressureMethodData(0, 1, 80), - CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), - CompressorElectricityData(0.40, 0.16), - 1)}; - - auto compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); - auto testOutput = compressedAirReduction.calculate(); - CHECK(testOutput.energyUse == Approx(55.296)); - CHECK(testOutput.energyCost == Approx(6.63552)); - CHECK(testOutput.flowRate == Approx(0.1)); - CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); - CHECK(testOutput.consumption == Approx(51840)); - - compressedAirReductionInputVec = { - CompressedAirReductionInput(3840, 1, 0.12, 6, - CompressedAirFlowMeterMethodData(200000), - BagMethodData(15, 10, 12), - PressureMethodData(0, 1, 80), - CompressedAirOtherMethodData(200000), - OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), - DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), - EstimateMethodData(0.1), - CompressorElectricityData(0.25, 0.16), - 1)}; - - compressedAirReduction = CompressedAirReduction(compressedAirReductionInputVec); - testOutput = compressedAirReduction.calculate(); - CHECK(testOutput.energyUse == Approx(15.36)); - CHECK(testOutput.energyCost == Approx(1.8432)); - CHECK(testOutput.flowRate == Approx(0.1)); - CHECK(testOutput.singleNozzleFlowRate == Approx(0.0)); - CHECK(testOutput.consumption == Approx(23040)); } \ No newline at end of file diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 0eee61e6..d2d771d4 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -264,29 +264,6 @@ test('Compressed Air Reduction Basic Test', function (t) { otherMethodData: { consumption: 200000 }, - orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 1 - }, - decibelsMethodData: { - linePressure: 130, - decibels: 25, - decibelRatingA: 20, - pressureA: 150, - firstFlowA: 1.04, - secondFlowA: 1.2, - decibelRatingB: 30, - pressureB: 125, - firstFlowB: 1.85, - secondFlowB: 1.65 - }, - estimateMethodData: { - leakRateEstimate: 0.1 - }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -303,74 +280,7 @@ test('Compressed Air Reduction Basic Test', function (t) { t.equal(rnd(res.singleNozzleFlowRate), rnd(0.0)); t.equal(rnd(res.consumption), rnd(103680000000.0)); }); -/* -test('Compressed Air Reduction Test (misc)', function (t) { - t.plan(6); - t.type(bindings.compressedAirReduction, 'function'); - var inp = { - compressedAirReductionInputVec: [ - { - hoursPerYear: 8640, - utilityType: 1, - utilityCost: 0.12, - measurementMethod: 5, - flowMeterMethodData: { - meterReading: 0 - }, - bagMethodData: { - height: 0, - diameter: 0, - fillTime: 0 - }, - pressureMethodData: { - nozzleType: 0, - numberOfNozzles: 1, - supplyPressure: 80 - }, - otherMethodData: { - consumption: 0 - }, - orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 0 - }, - decibelsMethodData: { - linePressure: 130, - decibels: 25, - decibelRatingA: 20, - pressureA: 150, - firstFlowA: 1.04, - secondFlowA: 1.2, - decibelRatingB: 30, - pressureB: 125, - firstFlowB: 1.85, - secondFlowB: 1.65 - }, - estimateMethodData: { - leakRateEstimate: 0 - }, - compressorElectricityData: { - compressorControlAdjustment: 0.4, - compressorSpecificPower: 0.16 - }, - units: 1 - } - ] - }; - - var res = bindings.compressedAirReduction(inp); - t.equal(rnd(res.energyUse), rnd(790.1798)); - t.equal(rnd(res.energyCost), rnd(94.8216)); - t.equal(rnd(res.flowRate), rnd(1.429)); - t.equal(rnd(res.singleNozzleFlowRate), rnd(0.0)); - t.equal(rnd(res.consumption), rnd(740793.6)); -}); -*/ test('Compressed Air Reduction Test All', function (t) { t.plan(6); t.type(bindings.compressedAirReduction, 'function'); @@ -404,29 +314,6 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, - orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 1 - }, - decibelsMethodData: { - linePressure: 130, - decibels: 25, - decibelRatingA: 20, - pressureA: 150, - firstFlowA: 1.04, - secondFlowA: 1.2, - decibelRatingB: 30, - pressureB: 125, - firstFlowB: 1.85, - secondFlowB: 1.65 - }, - estimateMethodData: { - leakRateEstimate: 0.1 - }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -460,29 +347,6 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, - orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 1 - }, - decibelsMethodData: { - linePressure: 130, - decibels: 25, - decibelRatingA: 20, - pressureA: 150, - firstFlowA: 1.04, - secondFlowA: 1.2, - decibelRatingB: 30, - pressureB: 125, - firstFlowB: 1.85, - secondFlowB: 1.65 - }, - estimateMethodData: { - leakRateEstimate: 0.1 - }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -514,29 +378,6 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, - orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 1 - }, - decibelsMethodData: { - linePressure: 130, - decibels: 25, - decibelRatingA: 20, - pressureA: 150, - firstFlowA: 1.04, - secondFlowA: 1.2, - decibelRatingB: 30, - pressureB: 125, - firstFlowB: 1.85, - secondFlowB: 1.65 - }, - estimateMethodData: { - leakRateEstimate: 0.1 - }, compressorElectricityData: { compressorControlAdjustment: 0.8, compressorSpecificPower: 0.16 @@ -568,13 +409,96 @@ test('Compressed Air Reduction Test All', function (t) { otherMethodData: { consumption: 200000 }, + compressorElectricityData: { + compressorControlAdjustment: 0.8, + compressorSpecificPower: 0.16 + }, + units: 1 + } + ] + }; + + var res = bindings.compressedAirReduction(inp); + t.equal(rnd(res.energyUse), rnd(2211881.965779)); + t.equal(rnd(res.energyCost), rnd(376063.261557)); + t.equal(rnd(res.flowRate), rnd(200005.187354)); + t.equal(rnd(res.singleNozzleFlowRate), rnd(1.778508)); + t.equal(rnd(res.consumption), rnd(103682889124.41486)); +}); + +test('Compressed Air Leak Survey Basic Test', function (t) { + t.plan(5); + t.type(bindings.compressedAirLeakSurvey, 'function'); + + var inp = { + compressedAirLeakSurveyInputVec: [ + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 0.1 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, orificeMethodData: { - compressorAirTemp: 0, - atmosphericPressure: 0, - dischargeCoefficient: 0, - orificeDiameter: 0, - supplyPressure: 0, - numberOfOrifices: 1 + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.40, + compressorSpecificPower: 0.16 + }, + units: 1 + } + ] + }; + + var res = bindings.compressedAirLeakSurvey(inp); + t.equal(rnd(res.energyUse), rnd(55.296)); + t.equal(rnd(res.energyCost), rnd(6.63552)); + t.equal(rnd(res.flowRate), rnd(0.1)); + t.equal(rnd(res.compressedAirUse), rnd(51840)); +}); + +test('Compressed Air Leak Survey Test All', function (t) { + t.plan(5); + t.type(bindings.compressedAirLeakSurvey, 'function'); + + var inp = { + compressedAirLeakSurveyInputVec: [ + // estimate method with electricity + // energyUse = 55.296 + // energyCost = 6.63552 + // flowRate = 0.1 + // compressedAirUse = 51840 + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 0.1 }, decibelsMethodData: { linePressure: 130, @@ -588,11 +512,153 @@ test('Compressed Air Reduction Test All', function (t) { firstFlowB: 1.85, secondFlowB: 1.65 }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.40, + compressorSpecificPower: 0.16 + }, + units: 1 + }, + // decibels method with electricity + // energyUse = 790.17984 + // energyCost = 94.8215808 + // flowRate = 1.429 + // compressedAirUse = 740793.6 + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 1, estimateMethodData: { leakRateEstimate: 0.1 }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, compressorElectricityData: { - compressorControlAdjustment: 0.8, + compressorControlAdjustment: 0.40, + compressorSpecificPower: 0.16 + }, + units: 1 + }, + // bag method with electricity + // energyUse = 3769.9111 + // energyCost = 452.3893 + // flowRate = 3.408846 + // compressedAirUse = 3534291.73528 + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 2, + estimateMethodData: { + leakRateEstimate: 0.1 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.40, + compressorSpecificPower: 0.16 + }, + units: 2 + }, + // orifice method with electricity + // energyUse = 1253583.3379004421 + // energyCost = 150430.000548053 + // flowRate = 2267.0416267007 + // compressedAirUse = 1175234379 + { + hoursPerYear: 8640, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 3, + estimateMethodData: { + leakRateEstimate: 0.1 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.40, compressorSpecificPower: 0.16 }, units: 1 @@ -600,15 +666,13 @@ test('Compressed Air Reduction Test All', function (t) { ] }; - var res = bindings.compressedAirReduction(inp); - t.equal(rnd(res.energyUse), rnd(2211881.965779)); - t.equal(rnd(res.energyCost), rnd(376063.261557)); - t.equal(rnd(res.flowRate), rnd(200005.187354)); - t.equal(rnd(res.singleNozzleFlowRate), rnd(1.778508)); - t.equal(rnd(res.consumption), rnd(103682889124.41486)); + var res = bindings.compressedAirLeakSurvey(inp); + t.equal(rnd(res.energyUse), rnd(1258198.724925)); + t.equal(rnd(res.energyCost), rnd(150983.846991)); + t.equal(rnd(res.flowRate), rnd(2271.979473)); + t.equal(rnd(res.compressedAirUse), rnd(1179561304.616953)); }); - test('Compressed Air Pressure Reduction - Baseline', function (t) { t.plan(3); t.type(bindings.compressedAirPressureReduction, 'function'); From 6e2acd48a61eb229ca7caba7e265c9a32bc78659 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 12 May 2020 13:41:40 -0400 Subject: [PATCH 200/217] Changed the units multiplicative factor from tmpFlowRate to tmpTotalCompressedAir calculation and added more tests --- .../util/CompressedAirLeakSurvey.cpp | 16 +- tests/CompressedAirLeakSurvey.unit.cpp | 18 +- tests/js/calculator.js | 176 +++++++++++++++++- 3 files changed, 199 insertions(+), 11 deletions(-) diff --git a/src/calculator/util/CompressedAirLeakSurvey.cpp b/src/calculator/util/CompressedAirLeakSurvey.cpp index 119d806e..2640e468 100644 --- a/src/calculator/util/CompressedAirLeakSurvey.cpp +++ b/src/calculator/util/CompressedAirLeakSurvey.cpp @@ -17,29 +17,29 @@ CompressedAirLeakSurvey::Output CompressedAirLeakSurvey::calculate() if(compressedAirLeakSurveyInput.getMeasurementMethod() == 0) { EstimateMethodData estimateMethodData = compressedAirLeakSurveyInput.getEstimateMethodData(); - tmpFlowRate = estimateMethodData.getLeakRateEstimate(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); + tmpFlowRate = estimateMethodData.getLeakRateEstimate() * compressedAirLeakSurveyInput.getUnits(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); } // decibels method else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 1) { DecibelsMethodData decibelsMethodData = compressedAirLeakSurveyInput.getDecibelsMethodData(); - tmpFlowRate = decibelsMethodData.calculate(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); + tmpFlowRate = decibelsMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); } // bag method else if (compressedAirLeakSurveyInput.getMeasurementMethod() == 2) { BagMethodData bagMethodData = compressedAirLeakSurveyInput.getBagMethodData(); - tmpFlowRate = (60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0)); - tmpTotalCompressedAirUse = tmpFlowRate * 60.0 * compressedAirLeakSurveyInput.getHoursPerYear() * compressedAirLeakSurveyInput.getUnits(); + tmpFlowRate = ((60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0))) * compressedAirLeakSurveyInput.getUnits(); + tmpTotalCompressedAirUse = tmpFlowRate * 60.0 * compressedAirLeakSurveyInput.getHoursPerYear(); } // orifice method else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 3) { OrificeMethodData orificeMethodData = compressedAirLeakSurveyInput.getOrificeMethodData(); - tmpFlowRate = orificeMethodData.calculate(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60) * compressedAirLeakSurveyInput.getUnits(); + tmpFlowRate = orificeMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); + tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); } //electricity calculation diff --git a/tests/CompressedAirLeakSurvey.unit.cpp b/tests/CompressedAirLeakSurvey.unit.cpp index 4ebd01f3..f00d9fb2 100644 --- a/tests/CompressedAirLeakSurvey.unit.cpp +++ b/tests/CompressedAirLeakSurvey.unit.cpp @@ -34,6 +34,22 @@ TEST_CASE("Compressed Air Leak Survey Estimate Method and Electricity", "[Compre CHECK(testOutput.energyCost == Approx(1.8432)); CHECK(testOutput.flowRate == Approx(0.1)); CHECK(testOutput.compressedAirUse == Approx(23040)); + + compressedAirLeakSurveyInputVec = { + CompressedAirLeakSurveyInput(8760, 1, 0.12, 0, + EstimateMethodData(100), + DecibelsMethodData(130, 25, 20, 150, 1.04, 1.2, 30, 125, 1.85, 1.65), + BagMethodData(15, 10, 12), + OrificeMethodData(250.0, 14.7, 1.0, 6.0, 6.2, 4), + CompressorElectricityData(0.25, 0.16), + 1)}; + + compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); + testOutput = compressedAirLeakSurvey.calculate(); + CHECK(testOutput.energyUse == Approx(35040)); + CHECK(testOutput.energyCost == Approx(4204.8)); + CHECK(testOutput.flowRate == Approx(100)); + CHECK(testOutput.compressedAirUse == Approx(52560000)); } TEST_CASE("Compressed Air Leak Survey Decibels Method and Electricity", "[CompressedAirLeakSurvey][Util]") @@ -70,7 +86,7 @@ TEST_CASE("Compressed Air Leak Survey Bag Method and Electricity", "[CompressedA auto testOutput = compressedAirLeakSurvey.calculate(); CHECK(testOutput.energyUse == Approx(3769.9111)); CHECK(testOutput.energyCost == Approx(452.3893)); - CHECK(testOutput.flowRate == Approx(3.408846)); + CHECK(testOutput.flowRate == Approx(6.8176923906)); CHECK(testOutput.compressedAirUse == Approx(3534291.73528)); } diff --git a/tests/js/calculator.js b/tests/js/calculator.js index d2d771d4..161994a3 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -481,6 +481,178 @@ test('Compressed Air Leak Survey Basic Test', function (t) { t.equal(rnd(res.compressedAirUse), rnd(51840)); }); +test('Compressed Air Leak Survey Additional Tests', function (t) { + t.plan(5); + t.type(bindings.compressedAirLeakSurvey, 'function'); + + var inp = { + compressedAirLeakSurveyInputVec: [ + { + hoursPerYear: 8760, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 100 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.25, + compressorSpecificPower: 0.16 + }, + units: 2 + }, + { + hoursPerYear: 8760, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 14 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.25, + compressorSpecificPower: 0.16 + }, + units: 1 + }, + { + hoursPerYear: 8760, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 0.785398163397448 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.25, + compressorSpecificPower: 0.16 + }, + units: 1 + }, + { + hoursPerYear: 8760, + utilityType: 1, + utilityCost: 0.12, + measurementMethod: 0, + estimateMethodData: { + leakRateEstimate: 6.32517756495803 + }, + decibelsMethodData: { + linePressure: 130, + decibels: 25, + decibelRatingA: 20, + pressureA: 150, + firstFlowA: 1.04, + secondFlowA: 1.2, + decibelRatingB: 30, + pressureB: 125, + firstFlowB: 1.85, + secondFlowB: 1.65 + }, + bagMethodData: { + height: 15, + diameter: 10, + fillTime: 12 + }, + orificeMethodData: { + compressorAirTemp: 250.0, + atmosphericPressure: 14.7, + dischargeCoefficient: 1.0, + orificeDiameter: 6.0, + supplyPressure: 6.2, + numberOfOrifices: 4 + }, + compressorElectricityData: { + compressorControlAdjustment: 0.25, + compressorSpecificPower: 0.16 + }, + units: 1 + } + ] + }; + + var res = bindings.compressedAirLeakSurvey(inp); + t.equal(rnd(res.energyUse), rnd(77477.145735)); + t.equal(rnd(res.energyCost), rnd(9297.257488)); + t.equal(rnd(res.flowRate), rnd(221.110576)); + t.equal(rnd(res.compressedAirUse), rnd(116215718.602824)); +}); + test('Compressed Air Leak Survey Test All', function (t) { t.plan(5); t.type(bindings.compressedAirLeakSurvey, 'function'); @@ -578,7 +750,7 @@ test('Compressed Air Leak Survey Test All', function (t) { // bag method with electricity // energyUse = 3769.9111 // energyCost = 452.3893 - // flowRate = 3.408846 + // flowRate = 6.8176923906 // compressedAirUse = 3534291.73528 { hoursPerYear: 8640, @@ -669,7 +841,7 @@ test('Compressed Air Leak Survey Test All', function (t) { var res = bindings.compressedAirLeakSurvey(inp); t.equal(rnd(res.energyUse), rnd(1258198.724925)); t.equal(rnd(res.energyCost), rnd(150983.846991)); - t.equal(rnd(res.flowRate), rnd(2271.979473)); + t.equal(rnd(res.flowRate), rnd(2275.388319)); // 2271.979473 t.equal(rnd(res.compressedAirUse), rnd(1179561304.616953)); }); From b14980b622e8a4cfc9b56314351abd2844fe5b8a Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 12 May 2020 14:31:35 -0400 Subject: [PATCH 201/217] Changed CompressedAirLeakSurvey output variable names --- bindings/calculator.h | 8 ++-- .../calculator/util/CompressedAirLeakSurvey.h | 7 +-- .../util/CompressedAirLeakSurvey.cpp | 36 +++++++------- tests/CompressedAirLeakSurvey.unit.cpp | 48 +++++++++---------- tests/js/calculator.js | 24 +++++----- 5 files changed, 62 insertions(+), 61 deletions(-) diff --git a/bindings/calculator.h b/bindings/calculator.h index 860cb9b6..4ce5c1d7 100644 --- a/bindings/calculator.h +++ b/bindings/calculator.h @@ -738,10 +738,10 @@ NAN_METHOD(compressedAirLeakSurvey) { std::vector inputVec = getCompressedAirLeakSurveyInputVec(); CompressedAirLeakSurvey::Output rv = CompressedAirLeakSurvey(inputVec).calculate(); - SetR("energyUse", rv.energyUse); - SetR("energyCost", rv.energyCost); - SetR("flowRate", rv.flowRate); - SetR("compressedAirUse", rv.compressedAirUse); + SetR("annualTotalElectricity", rv.annualTotalElectricity); + SetR("annualTotalElectricityCost", rv.annualTotalElectricityCost); + SetR("totalFlowRate", rv.totalFlowRate); + SetR("annualTotalFlowRate", rv.annualTotalFlowRate); } catch (std::runtime_error const &e) { diff --git a/include/calculator/util/CompressedAirLeakSurvey.h b/include/calculator/util/CompressedAirLeakSurvey.h index a761ad38..cd72cceb 100644 --- a/include/calculator/util/CompressedAirLeakSurvey.h +++ b/include/calculator/util/CompressedAirLeakSurvey.h @@ -135,11 +135,12 @@ class CompressedAirLeakSurvey public: struct Output { - Output(double energyUse, double energyCost, double flowRate, double compressedAirUse) - : energyUse(energyUse), energyCost(energyCost), flowRate(flowRate), compressedAirUse(compressedAirUse) {} + Output(double annualTotalElectricity, double annualTotalElectricityCost, double totalFlowRate, double annualTotalFlowRate) + : annualTotalElectricity(annualTotalElectricity), annualTotalElectricityCost(annualTotalElectricityCost), + totalFlowRate(totalFlowRate), annualTotalFlowRate(annualTotalFlowRate) {} Output() = default; - double energyUse = 0, energyCost = 0, flowRate = 0, compressedAirUse = 0; + double annualTotalElectricity = 0, annualTotalElectricityCost = 0, totalFlowRate = 0, annualTotalFlowRate = 0; }; CompressedAirLeakSurvey(std::vector &compressedAirLeakSurveyInputVec) : compressedAirLeakSurveyInputVec(compressedAirLeakSurveyInputVec) diff --git a/src/calculator/util/CompressedAirLeakSurvey.cpp b/src/calculator/util/CompressedAirLeakSurvey.cpp index 2640e468..d9be70a7 100644 --- a/src/calculator/util/CompressedAirLeakSurvey.cpp +++ b/src/calculator/util/CompressedAirLeakSurvey.cpp @@ -7,61 +7,61 @@ CompressedAirLeakSurvey::Output CompressedAirLeakSurvey::calculate() { - double totalEnergyUse = 0, totalEnergyCost = 0, totalFlowRate = 0, totalCompressedAirUse = 0; + double annualTotalElectricity = 0, annualTotalElectricityCost = 0, totalFlowRate = 0, annualTotalFlowRate = 0; for (auto &compressedAirLeakSurveyInput : compressedAirLeakSurveyInputVec) { - double tmpEnergyUse = 0, tmpEnergyCost = 0, tmpFlowRate = 0, tmpSingleNozzleFlowRate = 0, tmpTotalCompressedAirUse = 0; + double tmpAnnualTotalElectricity = 0, tmpAnnualTotalElectricityCost = 0, tmpTotalFlowRate = 0, tmpSingleNozzleFlowRate = 0, tmpAnnualTotalFlowRate = 0; // estimate method if(compressedAirLeakSurveyInput.getMeasurementMethod() == 0) { EstimateMethodData estimateMethodData = compressedAirLeakSurveyInput.getEstimateMethodData(); - tmpFlowRate = estimateMethodData.getLeakRateEstimate() * compressedAirLeakSurveyInput.getUnits(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); + tmpTotalFlowRate = estimateMethodData.getLeakRateEstimate() * compressedAirLeakSurveyInput.getUnits(); + tmpAnnualTotalFlowRate = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpTotalFlowRate * 60); } // decibels method else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 1) { DecibelsMethodData decibelsMethodData = compressedAirLeakSurveyInput.getDecibelsMethodData(); - tmpFlowRate = decibelsMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); + tmpTotalFlowRate = decibelsMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); + tmpAnnualTotalFlowRate = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpTotalFlowRate * 60); } // bag method else if (compressedAirLeakSurveyInput.getMeasurementMethod() == 2) { BagMethodData bagMethodData = compressedAirLeakSurveyInput.getBagMethodData(); - tmpFlowRate = ((60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0))) * compressedAirLeakSurveyInput.getUnits(); - tmpTotalCompressedAirUse = tmpFlowRate * 60.0 * compressedAirLeakSurveyInput.getHoursPerYear(); + tmpTotalFlowRate = ((60.0 / bagMethodData.getFillTime()) * M_PI * bagMethodData.getHeight() * pow((bagMethodData.getDiameter() / 2.0), 2.0) * (1.0 / pow(12.0, 3.0))) * compressedAirLeakSurveyInput.getUnits(); + tmpAnnualTotalFlowRate = tmpTotalFlowRate * 60.0 * compressedAirLeakSurveyInput.getHoursPerYear(); } // orifice method else if(compressedAirLeakSurveyInput.getMeasurementMethod() == 3) { OrificeMethodData orificeMethodData = compressedAirLeakSurveyInput.getOrificeMethodData(); - tmpFlowRate = orificeMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); - tmpTotalCompressedAirUse = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpFlowRate * 60); + tmpTotalFlowRate = orificeMethodData.calculate() * compressedAirLeakSurveyInput.getUnits(); + tmpAnnualTotalFlowRate = (compressedAirLeakSurveyInput.getHoursPerYear() * tmpTotalFlowRate * 60); } //electricity calculation if (compressedAirLeakSurveyInput.getUtilityType() == 0) { - tmpEnergyCost = compressedAirLeakSurveyInput.getUtilityCost() * tmpTotalCompressedAirUse; + tmpAnnualTotalElectricityCost = compressedAirLeakSurveyInput.getUtilityCost() * tmpAnnualTotalFlowRate; } else if (compressedAirLeakSurveyInput.getUtilityType() == 1) { CompressorElectricityData compressorElectricityData = compressedAirLeakSurveyInput.getCompressorElectricityData(); double electricityCalculation = compressorElectricityData.calculate(); - tmpEnergyUse = electricityCalculation * tmpTotalCompressedAirUse; - tmpEnergyCost = tmpEnergyUse * compressedAirLeakSurveyInput.getUtilityCost(); + tmpAnnualTotalElectricity = electricityCalculation * tmpAnnualTotalFlowRate; + tmpAnnualTotalElectricityCost = tmpAnnualTotalElectricity * compressedAirLeakSurveyInput.getUtilityCost(); } - totalEnergyUse += tmpEnergyUse; - totalEnergyCost += tmpEnergyCost; - totalFlowRate += tmpFlowRate; - totalCompressedAirUse += tmpTotalCompressedAirUse; + annualTotalElectricity += tmpAnnualTotalElectricity; + annualTotalElectricityCost += tmpAnnualTotalElectricityCost; + totalFlowRate += tmpTotalFlowRate; + annualTotalFlowRate += tmpAnnualTotalFlowRate; } - return CompressedAirLeakSurvey::Output(totalEnergyUse, totalEnergyCost, totalFlowRate, totalCompressedAirUse); + return CompressedAirLeakSurvey::Output(annualTotalElectricity, annualTotalElectricityCost, totalFlowRate, annualTotalFlowRate); } double DecibelsMethodData::calculate() diff --git a/tests/CompressedAirLeakSurvey.unit.cpp b/tests/CompressedAirLeakSurvey.unit.cpp index f00d9fb2..bb0fdb05 100644 --- a/tests/CompressedAirLeakSurvey.unit.cpp +++ b/tests/CompressedAirLeakSurvey.unit.cpp @@ -14,10 +14,10 @@ TEST_CASE("Compressed Air Leak Survey Estimate Method and Electricity", "[Compre auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); auto testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(55.296)); - CHECK(testOutput.energyCost == Approx(6.63552)); - CHECK(testOutput.flowRate == Approx(0.1)); - CHECK(testOutput.compressedAirUse == Approx(51840)); + CHECK(testOutput.annualTotalElectricity == Approx(55.296)); + CHECK(testOutput.annualTotalElectricityCost == Approx(6.63552)); + CHECK(testOutput.totalFlowRate == Approx(0.1)); + CHECK(testOutput.annualTotalFlowRate == Approx(51840)); compressedAirLeakSurveyInputVec = { CompressedAirLeakSurveyInput(3840, 1, 0.12, 0, @@ -30,10 +30,10 @@ TEST_CASE("Compressed Air Leak Survey Estimate Method and Electricity", "[Compre compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(15.36)); - CHECK(testOutput.energyCost == Approx(1.8432)); - CHECK(testOutput.flowRate == Approx(0.1)); - CHECK(testOutput.compressedAirUse == Approx(23040)); + CHECK(testOutput.annualTotalElectricity == Approx(15.36)); + CHECK(testOutput.annualTotalElectricityCost == Approx(1.8432)); + CHECK(testOutput.totalFlowRate == Approx(0.1)); + CHECK(testOutput.annualTotalFlowRate == Approx(23040)); compressedAirLeakSurveyInputVec = { CompressedAirLeakSurveyInput(8760, 1, 0.12, 0, @@ -46,10 +46,10 @@ TEST_CASE("Compressed Air Leak Survey Estimate Method and Electricity", "[Compre compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(35040)); - CHECK(testOutput.energyCost == Approx(4204.8)); - CHECK(testOutput.flowRate == Approx(100)); - CHECK(testOutput.compressedAirUse == Approx(52560000)); + CHECK(testOutput.annualTotalElectricity == Approx(35040)); + CHECK(testOutput.annualTotalElectricityCost == Approx(4204.8)); + CHECK(testOutput.totalFlowRate == Approx(100)); + CHECK(testOutput.annualTotalFlowRate == Approx(52560000)); } TEST_CASE("Compressed Air Leak Survey Decibels Method and Electricity", "[CompressedAirLeakSurvey][Util]") @@ -65,10 +65,10 @@ TEST_CASE("Compressed Air Leak Survey Decibels Method and Electricity", "[Compre auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); auto testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(790.17984)); - CHECK(testOutput.energyCost == Approx(94.8215808)); - CHECK(testOutput.flowRate == Approx(1.429)); - CHECK(testOutput.compressedAirUse == Approx(740793.6)); + CHECK(testOutput.annualTotalElectricity == Approx(790.17984)); + CHECK(testOutput.annualTotalElectricityCost == Approx(94.8215808)); + CHECK(testOutput.totalFlowRate == Approx(1.429)); + CHECK(testOutput.annualTotalFlowRate == Approx(740793.6)); } TEST_CASE("Compressed Air Leak Survey Bag Method and Electricity", "[CompressedAirLeakSurvey][Util]") @@ -84,10 +84,10 @@ TEST_CASE("Compressed Air Leak Survey Bag Method and Electricity", "[CompressedA auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); auto testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(3769.9111)); - CHECK(testOutput.energyCost == Approx(452.3893)); - CHECK(testOutput.flowRate == Approx(6.8176923906)); - CHECK(testOutput.compressedAirUse == Approx(3534291.73528)); + CHECK(testOutput.annualTotalElectricity == Approx(3769.9111)); + CHECK(testOutput.annualTotalElectricityCost == Approx(452.3893)); + CHECK(testOutput.totalFlowRate == Approx(6.8176923906)); + CHECK(testOutput.annualTotalFlowRate == Approx(3534291.73528)); } TEST_CASE("Compressed Air Leak Survey Orifice Method and Electricity", "[CompressedAirLeakSurvey][Util]") @@ -103,8 +103,8 @@ TEST_CASE("Compressed Air Leak Survey Orifice Method and Electricity", "[Compres auto compressedAirLeakSurvey = CompressedAirLeakSurvey(compressedAirLeakSurveyInputVec); auto testOutput = compressedAirLeakSurvey.calculate(); - CHECK(testOutput.energyUse == Approx(1253583.3379004421)); - CHECK(testOutput.energyCost == Approx(150430.000548053)); - CHECK(testOutput.flowRate == Approx(2267.0416267007)); - CHECK(testOutput.compressedAirUse == Approx(1175234379)); + CHECK(testOutput.annualTotalElectricity == Approx(1253583.3379004421)); + CHECK(testOutput.annualTotalElectricityCost == Approx(150430.000548053)); + CHECK(testOutput.totalFlowRate == Approx(2267.0416267007)); + CHECK(testOutput.annualTotalFlowRate == Approx(1175234379)); } \ No newline at end of file diff --git a/tests/js/calculator.js b/tests/js/calculator.js index 161994a3..f17b9220 100644 --- a/tests/js/calculator.js +++ b/tests/js/calculator.js @@ -475,10 +475,10 @@ test('Compressed Air Leak Survey Basic Test', function (t) { }; var res = bindings.compressedAirLeakSurvey(inp); - t.equal(rnd(res.energyUse), rnd(55.296)); - t.equal(rnd(res.energyCost), rnd(6.63552)); - t.equal(rnd(res.flowRate), rnd(0.1)); - t.equal(rnd(res.compressedAirUse), rnd(51840)); + t.equal(rnd(res.annualTotalElectricity), rnd(55.296)); + t.equal(rnd(res.annualTotalElectricityCost), rnd(6.63552)); + t.equal(rnd(res.totalFlowRate), rnd(0.1)); + t.equal(rnd(res.annualTotalFlowRate), rnd(51840)); }); test('Compressed Air Leak Survey Additional Tests', function (t) { @@ -647,10 +647,10 @@ test('Compressed Air Leak Survey Additional Tests', function (t) { }; var res = bindings.compressedAirLeakSurvey(inp); - t.equal(rnd(res.energyUse), rnd(77477.145735)); - t.equal(rnd(res.energyCost), rnd(9297.257488)); - t.equal(rnd(res.flowRate), rnd(221.110576)); - t.equal(rnd(res.compressedAirUse), rnd(116215718.602824)); + t.equal(rnd(res.annualTotalElectricity), rnd(77477.145735)); + t.equal(rnd(res.annualTotalElectricityCost), rnd(9297.257488)); + t.equal(rnd(res.totalFlowRate), rnd(221.110576)); + t.equal(rnd(res.annualTotalFlowRate), rnd(116215718.602824)); }); test('Compressed Air Leak Survey Test All', function (t) { @@ -839,10 +839,10 @@ test('Compressed Air Leak Survey Test All', function (t) { }; var res = bindings.compressedAirLeakSurvey(inp); - t.equal(rnd(res.energyUse), rnd(1258198.724925)); - t.equal(rnd(res.energyCost), rnd(150983.846991)); - t.equal(rnd(res.flowRate), rnd(2275.388319)); // 2271.979473 - t.equal(rnd(res.compressedAirUse), rnd(1179561304.616953)); + t.equal(rnd(res.annualTotalElectricity), rnd(1258198.724925)); + t.equal(rnd(res.annualTotalElectricityCost), rnd(150983.846991)); + t.equal(rnd(res.totalFlowRate), rnd(2275.388319)); // 2271.979473 + t.equal(rnd(res.annualTotalFlowRate), rnd(1179561304.616953)); }); test('Compressed Air Pressure Reduction - Baseline', function (t) { From bb80f0d960efa86848a7a6e8e5addf3592827819 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 12 May 2020 16:41:01 -0400 Subject: [PATCH 202/217] Updated wet bulb calculations --- include/fans/Fan203.h | 146 ++++++++++++++++++++++++++++++++++++++---- tests/Fan.unit.cpp | 19 ++++++ 2 files changed, 154 insertions(+), 11 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 75273fa1..167d1d4f 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -79,7 +79,7 @@ class BaseGasDensity * @param inputType const, type of input, unitless * @param specificGravity, double, const, specific gravity, unitless * @return gasDensity double, density of the gas in pounds per sqft, lb/scf - * @return absolutePressure double, Absolute Pressure In in in Hg XXX + * @return absolutePressure double, Absolute Pressure In in in Hg * @return saturatedHumidity double, Saturated Humidity Ratio, unitless * @return saturationDegree double, Degree of Saturation, unitless * @return humidityRatio double, Humidity Ratio, unitless @@ -112,6 +112,8 @@ class BaseGasDensity calculateFanAttributes(inputType, relativeHumidityOrDewPoint); + wetBulbTemp = calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, barometricPressure); + /* std::ofstream fout; fout.open("debug.txt", std::ios::app); @@ -128,12 +130,24 @@ class BaseGasDensity fout << "------------------------------" << std::endl << std::endl; fout.close(); */ + /* + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "Wet Bulb Temperature Test" << std::endl << std::endl; + fout << "dryBulbTemp: " << "45.00" << std::endl; + fout << "relativeHumidity: " << 50.0 / 100 << std::endl; + fout << "barometricPressure: " << "29.28" << std::endl; + fout << std::endl; + fout << "wetBulbTemp: " << calculateWetBulbTemperature(45.00, 50.0 / 100, 29.28) << std::endl; + fout << std::endl; + fout.close(); + */ } BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, double const wetBulbTemp, GasType const gasType, InputType const inputType, double const specificGravity, const double cpGas) - : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), g(specificGravity), gasType(gasType) + : tdo(dryBulbTemp), pso(staticPressure), pbo(barometricPressure), wetBulbTemp(wetBulbTemp), g(specificGravity), gasType(gasType) { if (inputType != InputType::WetBulbTemp) throw std::runtime_error("The wrong constructor for BaseGasDensity was called - check inputType field"); @@ -159,31 +173,44 @@ class BaseGasDensity fout << "------------------------------" << std::endl << std::endl; fout.close(); */ + + /* + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "Wet Bulb Temperature Test" << std::endl << std::endl; + fout << "dryBulbTemp: " << dryBulbTemp << std::endl; + fout << "relativeHumidity: " << relativeHumidity << std::endl; + fout << "barometricPressure: " << barometricPressure << std::endl; + fout << std::endl; + fout << "wetBulbTemp: " << calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, barometricPressure) << std::endl; + fout << std::endl; + fout.close(); + */ } double getGasDensity() const { - return gasDensity; + return gasDensity; // po } double getAbsolutePressureIn() const { - return absolutePressure; + return absolutePressure; // pIn } double getSaturatedHumidityRatio() const { - return saturatedHumidity; + return saturatedHumidity; // satW } double getDegreeOfSaturation() const { - return saturationDegree; + return saturationDegree; // satDeg } double getHumidityRatio() const { - return humidityRatio; + return humidityRatio; // humW } double getSpecificVolume() const { - return specificVolume; + return specificVolume; // specVol } double getEnthalpy() const { @@ -195,15 +222,85 @@ class BaseGasDensity } double getRelativeHumidity() const { - return relativeHumidity; + return relativeHumidity; // rh } double getSaturationPressure() const { - return saturationPressure; + return saturationPressure; // satPress + } + double getWetBulbTemp() const + { + return wetBulbTemp; // Tdb } private: /** + * @brief Calculates Wet Bulb Temperature + * + * @param dryBulbTemp double, temperature of inputted air in °F + * @param relativeHumidity double, Relative Humidity, % + * @param barometricPressure, double, const, pressure in Hg + * @return wetBulbTemp double, Wet Bulb Temperature, °F + */ + double calculateWetBulbTemperature(double dryBulbTemp, double relativeHumidity, double barometricPressure) const + { + //Tdb = (dryBulbTemp * (9/5)) + 32; // Convert to + double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, barometricPressure, 1); // Hum_rat2 + //double humidityRatioNormal = getHumidityRatio(); + double wetBulbTemp = dryBulbTemp; // set initial guess + //double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, barometricPressure); // Hum_rat + //double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); // MOVE INSIDE LOOP + //double humidityRatioNew = 0.50255; + + ///* + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "----------START OF 'calculateWetBulbTemperature'----------" << std::endl; + fout << "Parameters:" << std::endl; + fout << "--------------" << std::endl; + fout << "dryBulbTemp: " << dryBulbTemp << std::endl; + fout << "relativeHumidity: " << relativeHumidity << std::endl; + fout << "barometricPressure: " << barometricPressure << std::endl; + fout << std::endl; + fout << "Before Loop:" << std::endl; + fout << "--------------" << std::endl; + fout << "humidityRatioNormal: " << humidityRatioNormal << std::endl; + fout << "wetBulbTemp: " << wetBulbTemp << std::endl; + //fout << "humidityRatioNew: " << humidityRatioNew << std::endl; + fout << std::endl; + //fout.close(); + int iteration = 1; + //*/ + + // Use Newton-Raphson iteration to quickly solve to within 0.001% accuracy + double humidityRatioNew; + do + { + humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); + double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, barometricPressure); + double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; + wetBulbTemp = wetBulbTemp - (humidityRatioNew - humidityRatioNormal) / dw_dtwb; + //humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, barometricPressure); + fout << "Iteration: " << iteration << std::endl; + fout << "--------------" << std::endl; + iteration++; + fout << "humidityRatioNew: " << humidityRatioNew << std::endl; + fout << "humidityRatioNew2: " << humidityRatioNew2 << std::endl; + fout << "dw_dtwb: " << dw_dtwb << std::endl; + fout << "wetBulbTemp: " << wetBulbTemp << std::endl; + fout << "humidityRatioNew: " << humidityRatioNew << std::endl; + fout << std::endl; + + } while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001); + + fout << "Final wetBulbTemp: " << wetBulbTemp << std::endl; + fout << "----------END OF 'calculateWetBulbTemperature'----------" << std::endl; + fout << std::endl; + fout.close(); + + return wetBulbTemp; + } + /** * @brief Calculates Saturation Pressure * * @param dryBulbTemp double, temperature of inputted air in °F @@ -248,6 +345,13 @@ class BaseGasDensity double calculateRatioRH(const double dryBulbTemp, const double relativeHumidity, const double barometricPressure, const double specificGravity) const { + std::ofstream fout; + fout.open("debug.txt", std::ios::app); + fout << "----------START OF 'calculateRatioRH'----------" << std::endl; + fout << "saturationPressure: " << calculateSaturationPressure(dryBulbTemp) << std::endl; + fout << "----------END OF 'calculateRatioRH'----------" << std::endl; + fout << std::endl; + fout.close(); auto const pw = (calculateSaturationPressure(dryBulbTemp) * relativeHumidity); return (18.02 / (specificGravity * 28.98)) * pw / (barometricPressure - pw); } @@ -287,6 +391,25 @@ class BaseGasDensity return pV / psatDb; } /** + * @brief Calculates Relative Humidity Ratio from Wet Bulb Temperature + * + * @param dryBulbTemp double, temperature of inputted air in °F + * @param wetBulbTemp double, wet bulb temperature in °F + * @param cpGas double, BTU/lb-degF + * @return humidityRatio double, Humidity Ratio, unitless + */ + double calculateHumidityRatioFromWetBulb(const double dryBulbTemp, const double wetBulbTemp, const double cpGas) const + { + double const nMol = 0.62198; + double const local_pIn = pbo + (pso / 13.608703); + + double const psatWb = calculateSaturationPressure(wetBulbTemp); + double const wStar = nMol * psatWb / (local_pIn - psatWb); + double const w = ((1093 - (1 - 0.444) * wetBulbTemp) * wStar - cpGas * (dryBulbTemp - wetBulbTemp)) / (1093 + (0.444 * dryBulbTemp) - wetBulbTemp); + + return w; + } + /** * @brief Calculates numerous fan attributes. Note: This function assumes that the member variables pbo, pso, saturationPressure, and relativeHumidity already have valid values. * @@ -346,8 +469,9 @@ class BaseGasDensity * @param dewPoint double, Dewpoint, deg F * @param relativeHumidity double, Relative Humidity, % * @param saturationPressure double, Saturation Pressure, in Hg + * @param wetBulbTemp double, Wet Bulb Temperature, deg F */ - double absolutePressure, saturatedHumidity, saturationDegree, humidityRatio, specificVolume, enthalpy, dewPoint, relativeHumidity, saturationPressure; + double absolutePressure, saturatedHumidity, saturationDegree, humidityRatio, specificVolume, enthalpy, dewPoint, relativeHumidity, saturationPressure, wetBulbTemp; friend class PlaneData; friend class Fan203; diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 6d5d99c0..0fdfe930 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -179,6 +179,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg.getDewPoint() == Approx(55.5539)); CHECK(bdg.getRelativeHumidity() == Approx(0.60)); CHECK(bdg.getSaturationPressure() == Approx(0.739659)); + //CHECK(bdg.getWetBulbTemp() == Approx(1)); auto const bdg2 = BaseGasDensity( 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 @@ -194,6 +195,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg2.getDewPoint() == Approx(55.5)); CHECK(bdg2.getRelativeHumidity() == Approx(0.600175)); CHECK(bdg2.getSaturationPressure() == Approx(0.739659)); + //CHECK(bdg2.getWetBulbTemp() == Approx(1)); auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 @@ -209,4 +211,21 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg3.getDewPoint() == Approx(55.5664)); CHECK(bdg3.getRelativeHumidity() == Approx(0.600272)); CHECK(bdg3.getSaturationPressure() == Approx(0.739659)); + //CHECK(bdg3.getWetBulbTemp() == Approx(1)); + + auto const bdg4 = BaseGasDensity( // 0, 29.28 + 45, 0, 29.28, 50, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 + ); + + CHECK(bdg4.getGasDensity() == Approx(0.0767611631)); + CHECK(bdg4.getAbsolutePressureIn() == Approx(29.28)); + CHECK(bdg4.getSaturatedHumidityRatio() == Approx(0.0064480269)); + CHECK(bdg4.getDegreeOfSaturation() == Approx(0.4974216309)); + CHECK(bdg4.getHumidityRatio() == Approx(0.0032073881)); + CHECK(bdg4.getSpecificVolume() == Approx(13.0692051516)); + CHECK(bdg4.getEnthalpy() == Approx(14.5821223583)); + CHECK(bdg4.getDewPoint() == Approx(27.3784844278)); + CHECK(bdg4.getRelativeHumidity() == Approx(0.5)); + CHECK(bdg4.getSaturationPressure() == Approx(0.3004293578)); + //CHECK(bdg4.getWetBulbTemp() == Approx(1)); } From b071c053fb4e2242dca0b5b9c80d410a1e647bc2 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 13 May 2020 10:45:02 -0400 Subject: [PATCH 203/217] Updated wet bulb calculation --- include/fans/Fan203.h | 19 +++++++++++++------ tests/Fan.unit.cpp | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 167d1d4f..00c4a9ff 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -273,13 +273,20 @@ class BaseGasDensity //*/ // Use Newton-Raphson iteration to quickly solve to within 0.001% accuracy - double humidityRatioNew; - do + //double humidityRatioNew; + double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); + double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); + fout << "humidityRatioNew: " << humidityRatioNew << std::endl; + fout << "humidityRatioNew2: " << humidityRatioNew2 << std::endl; + while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001) { - humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); - double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, barometricPressure); double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; wetBulbTemp = wetBulbTemp - (humidityRatioNew - humidityRatioNormal) / dw_dtwb; + + humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); + humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); + //double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; + //wetBulbTemp = wetBulbTemp - (humidityRatioNew - humidityRatioNormal) / dw_dtwb; //humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, barometricPressure); fout << "Iteration: " << iteration << std::endl; fout << "--------------" << std::endl; @@ -288,10 +295,10 @@ class BaseGasDensity fout << "humidityRatioNew2: " << humidityRatioNew2 << std::endl; fout << "dw_dtwb: " << dw_dtwb << std::endl; fout << "wetBulbTemp: " << wetBulbTemp << std::endl; - fout << "humidityRatioNew: " << humidityRatioNew << std::endl; + //fout << "humidityRatioNew: " << humidityRatioNew << std::endl; fout << std::endl; - } while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001); + } fout << "Final wetBulbTemp: " << wetBulbTemp << std::endl; fout << "----------END OF 'calculateWetBulbTemperature'----------" << std::endl; diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index 0fdfe930..dd779934 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -179,7 +179,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg.getDewPoint() == Approx(55.5539)); CHECK(bdg.getRelativeHumidity() == Approx(0.60)); CHECK(bdg.getSaturationPressure() == Approx(0.739659)); - //CHECK(bdg.getWetBulbTemp() == Approx(1)); + CHECK(bdg.getWetBulbTemp() == Approx(1)); auto const bdg2 = BaseGasDensity( 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 @@ -217,15 +217,15 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { 45, 0, 29.28, 50, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); - CHECK(bdg4.getGasDensity() == Approx(0.0767611631)); - CHECK(bdg4.getAbsolutePressureIn() == Approx(29.28)); - CHECK(bdg4.getSaturatedHumidityRatio() == Approx(0.0064480269)); - CHECK(bdg4.getDegreeOfSaturation() == Approx(0.4974216309)); - CHECK(bdg4.getHumidityRatio() == Approx(0.0032073881)); - CHECK(bdg4.getSpecificVolume() == Approx(13.0692051516)); + CHECK(bdg4.getGasDensity() == Approx(0.0767611631)); // po, density + CHECK(bdg4.getAbsolutePressureIn() == Approx(29.28)); // pIn + CHECK(bdg4.getSaturatedHumidityRatio() == Approx(0.0064480269)); // satW + CHECK(bdg4.getDegreeOfSaturation() == Approx(0.4974216309)); // satDeg + CHECK(bdg4.getHumidityRatio() == Approx(0.0032073881)); // humW + CHECK(bdg4.getSpecificVolume() == Approx(13.0692051516)); // specVol CHECK(bdg4.getEnthalpy() == Approx(14.5821223583)); CHECK(bdg4.getDewPoint() == Approx(27.3784844278)); - CHECK(bdg4.getRelativeHumidity() == Approx(0.5)); - CHECK(bdg4.getSaturationPressure() == Approx(0.3004293578)); - //CHECK(bdg4.getWetBulbTemp() == Approx(1)); + CHECK(bdg4.getRelativeHumidity() == Approx(0.5)); // rh + CHECK(bdg4.getSaturationPressure() == Approx(0.3004293578)); // satPress + //CHECK(bdg4.getWetBulbTemp() == Approx(37.7031851555)); // Tdb } From 7078158078e7f8c2f557de3522ec14ddf0bd3e51 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 13 May 2020 11:32:41 -0400 Subject: [PATCH 204/217] Ready for PR --- bindings/standalone.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/bindings/standalone.h b/bindings/standalone.h index f74938d8..479c5701 100644 --- a/bindings/standalone.h +++ b/bindings/standalone.h @@ -354,17 +354,6 @@ NAN_METHOD(bagMethod) { info.GetReturnValue().Set(r); } -/* -NAN_METHOD(estimateMethod) { - inp = Nan::To(info[0]).ToLocalChecked(); - r = Nan::New(); - - //ReceiverTank::Method method = static_cast(static_cast(Get("method"))); - //std::string const &leakEstimateTypeStr = GetStr("leakEstimateType"); - EstimateMethod::LeakEstimateType leakEstimateType = static_cast(static_cast(Get("leakEstimateType"))); - const double operatingTime = Get("operatingTime"); - -} -*/ +// TODO: Add estimate, orifice, and decibels methods in the future #endif //AMO_TOOLS_SUITE_STANDALONE_H From ed51e40fc48e94780d79d39f68ccb4cc9690f746 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 13 May 2020 17:25:46 -0400 Subject: [PATCH 205/217] All tests passing --- bindings/fan.h | 2 ++ include/fans/Fan203.h | 75 +++++++------------------------------------ tests/Fan.unit.cpp | 12 +++---- tests/js/fanTest.js | 9 ++++-- 4 files changed, 27 insertions(+), 71 deletions(-) diff --git a/bindings/fan.h b/bindings/fan.h index 07f24a33..49b66267 100644 --- a/bindings/fan.h +++ b/bindings/fan.h @@ -448,6 +448,7 @@ void SetBaseGasDensityData(Local & obj, const BaseGasDensity & bgd) Local dewPoint = Nan::New("dewPoint").ToLocalChecked(); Local relativeHumidity = Nan::New("relativeHumidity").ToLocalChecked(); Local saturationPressure = Nan::New("saturationPressure").ToLocalChecked(); + Local wetBulbTemp = Nan::New("wetBulbTemp").ToLocalChecked(); Nan::Set(obj, gasDensity, Nan::New(bgd.getGasDensity())); Nan::Set(obj, absolutePressure, Nan::New(bgd.getAbsolutePressureIn())); @@ -459,6 +460,7 @@ void SetBaseGasDensityData(Local & obj, const BaseGasDensity & bgd) Nan::Set(obj, dewPoint, Nan::New(bgd.getDewPoint())); Nan::Set(obj, relativeHumidity, Nan::New(bgd.getRelativeHumidity())); Nan::Set(obj, saturationPressure, Nan::New(bgd.getSaturationPressure())); + Nan::Set(obj, wetBulbTemp, Nan::New(bgd.getWetBulbTemp())); } NAN_METHOD(getBaseGasDensityRelativeHumidity) { diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 00c4a9ff..d46eca6a 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -112,7 +112,7 @@ class BaseGasDensity calculateFanAttributes(inputType, relativeHumidityOrDewPoint); - wetBulbTemp = calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, barometricPressure); + //wetBulbTemp = calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, absolutePressure); //barometricPressure /* std::ofstream fout; @@ -155,7 +155,7 @@ class BaseGasDensity relativeHumidity = calculateRelativeHumidityFromWetBulb(tdo, wetBulbTemp, cpGas); calculateFanAttributes(inputType); - + /* std::ofstream fout; fout.open("debug.txt", std::ios::app); @@ -242,69 +242,20 @@ class BaseGasDensity * @param barometricPressure, double, const, pressure in Hg * @return wetBulbTemp double, Wet Bulb Temperature, °F */ - double calculateWetBulbTemperature(double dryBulbTemp, double relativeHumidity, double barometricPressure) const + double calculateWetBulbTemperature(double dryBulbTemp, double relativeHumidity, double absolutePressure) const { - //Tdb = (dryBulbTemp * (9/5)) + 32; // Convert to - double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, barometricPressure, 1); // Hum_rat2 - //double humidityRatioNormal = getHumidityRatio(); + double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, absolutePressure, 1); // Hum_rat2 double wetBulbTemp = dryBulbTemp; // set initial guess - //double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, barometricPressure); // Hum_rat - //double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); // MOVE INSIDE LOOP - //double humidityRatioNew = 0.50255; - - ///* - std::ofstream fout; - fout.open("debug.txt", std::ios::app); - fout << "----------START OF 'calculateWetBulbTemperature'----------" << std::endl; - fout << "Parameters:" << std::endl; - fout << "--------------" << std::endl; - fout << "dryBulbTemp: " << dryBulbTemp << std::endl; - fout << "relativeHumidity: " << relativeHumidity << std::endl; - fout << "barometricPressure: " << barometricPressure << std::endl; - fout << std::endl; - fout << "Before Loop:" << std::endl; - fout << "--------------" << std::endl; - fout << "humidityRatioNormal: " << humidityRatioNormal << std::endl; - fout << "wetBulbTemp: " << wetBulbTemp << std::endl; - //fout << "humidityRatioNew: " << humidityRatioNew << std::endl; - fout << std::endl; - //fout.close(); - int iteration = 1; - //*/ - - // Use Newton-Raphson iteration to quickly solve to within 0.001% accuracy - //double humidityRatioNew; - double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); - double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); - fout << "humidityRatioNew: " << humidityRatioNew << std::endl; - fout << "humidityRatioNew2: " << humidityRatioNew2 << std::endl; + double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); // MOVE INSIDE LOOP + while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001) { + double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; wetBulbTemp = wetBulbTemp - (humidityRatioNew - humidityRatioNormal) / dw_dtwb; - humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); - humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); - //double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; - //wetBulbTemp = wetBulbTemp - (humidityRatioNew - humidityRatioNormal) / dw_dtwb; - //humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, barometricPressure); - fout << "Iteration: " << iteration << std::endl; - fout << "--------------" << std::endl; - iteration++; - fout << "humidityRatioNew: " << humidityRatioNew << std::endl; - fout << "humidityRatioNew2: " << humidityRatioNew2 << std::endl; - fout << "dw_dtwb: " << dw_dtwb << std::endl; - fout << "wetBulbTemp: " << wetBulbTemp << std::endl; - //fout << "humidityRatioNew: " << humidityRatioNew << std::endl; - fout << std::endl; - } - fout << "Final wetBulbTemp: " << wetBulbTemp << std::endl; - fout << "----------END OF 'calculateWetBulbTemperature'----------" << std::endl; - fout << std::endl; - fout.close(); - return wetBulbTemp; } /** @@ -352,13 +303,6 @@ class BaseGasDensity double calculateRatioRH(const double dryBulbTemp, const double relativeHumidity, const double barometricPressure, const double specificGravity) const { - std::ofstream fout; - fout.open("debug.txt", std::ios::app); - fout << "----------START OF 'calculateRatioRH'----------" << std::endl; - fout << "saturationPressure: " << calculateSaturationPressure(dryBulbTemp) << std::endl; - fout << "----------END OF 'calculateRatioRH'----------" << std::endl; - fout << std::endl; - fout.close(); auto const pw = (calculateSaturationPressure(dryBulbTemp) * relativeHumidity); return (18.02 / (specificGravity * 28.98)) * pw / (barometricPressure - pw); } @@ -453,6 +397,11 @@ class BaseGasDensity { dewPoint = relativeHumidityOrDewPoint; } + + if(inputType != InputType::WetBulbTemp) // If not given as an input, calculate wet bulb temperature + { + wetBulbTemp = calculateWetBulbTemperature(tdo, relativeHumidity, absolutePressure); + } } // dry bulb temp, reference static pressure, reference barometric pressure, gas density respectively diff --git a/tests/Fan.unit.cpp b/tests/Fan.unit.cpp index dd779934..926ffec1 100644 --- a/tests/Fan.unit.cpp +++ b/tests/Fan.unit.cpp @@ -179,7 +179,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg.getDewPoint() == Approx(55.5539)); CHECK(bdg.getRelativeHumidity() == Approx(0.60)); CHECK(bdg.getSaturationPressure() == Approx(0.739659)); - CHECK(bdg.getWetBulbTemp() == Approx(1)); + CHECK(bdg.getWetBulbTemp() == Approx(61.1895184019)); auto const bdg2 = BaseGasDensity( 70, 26.62, 29.92, 55.5, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::DewPoint, 1 @@ -195,7 +195,7 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg2.getDewPoint() == Approx(55.5)); CHECK(bdg2.getRelativeHumidity() == Approx(0.600175)); CHECK(bdg2.getSaturationPressure() == Approx(0.739659)); - //CHECK(bdg2.getWetBulbTemp() == Approx(1)); + CHECK(bdg2.getWetBulbTemp() == Approx(61.1937398807)); auto const bdg3 = BaseGasDensity( 70, 26.62, 29.92, 61.2, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::WetBulbTemp, 1, 0.24 @@ -211,9 +211,9 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg3.getDewPoint() == Approx(55.5664)); CHECK(bdg3.getRelativeHumidity() == Approx(0.600272)); CHECK(bdg3.getSaturationPressure() == Approx(0.739659)); - //CHECK(bdg3.getWetBulbTemp() == Approx(1)); - - auto const bdg4 = BaseGasDensity( // 0, 29.28 + CHECK(bdg3.getWetBulbTemp() == Approx(61.2)); + + auto const bdg4 = BaseGasDensity( 45, 0, 29.28, 50, BaseGasDensity::GasType::AIR, BaseGasDensity::InputType::RelativeHumidity, 1 ); @@ -227,5 +227,5 @@ TEST_CASE( "BaseGasDensity", "[BaseGasDensity]") { CHECK(bdg4.getDewPoint() == Approx(27.3784844278)); CHECK(bdg4.getRelativeHumidity() == Approx(0.5)); // rh CHECK(bdg4.getSaturationPressure() == Approx(0.3004293578)); // satPress - //CHECK(bdg4.getWetBulbTemp() == Approx(37.7031851555)); // Tdb + CHECK(bdg4.getWetBulbTemp() == Approx(37.7031079652)); // Tdb } diff --git a/tests/js/fanTest.js b/tests/js/fanTest.js index 3d364f4a..c0b71d60 100644 --- a/tests/js/fanTest.js +++ b/tests/js/fanTest.js @@ -165,7 +165,7 @@ test('fan203 test', function (t) { test('getBaseGasDensity', function (t) { //t.plan(6); - t.plan(63); + t.plan(69); // 63 t.type(bindings.getBaseGasDensityRelativeHumidity, 'function'); t.type(bindings.getBaseGasDensityDewPoint, 'function'); t.type(bindings.getBaseGasDensityWetBulb, 'function'); @@ -193,6 +193,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(87.403871)); t.equal(rnd(res.relativeHumidity), rnd(0.35)); t.equal(rnd(res.saturationPressure), rnd(3.748742)); + t.equal(rnd(res.wetBulbTemp), rnd(93.258046)); inp = { dryBulbTemp: 70, @@ -216,6 +217,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(55.553919)); t.equal(rnd(res.relativeHumidity), rnd(0.60)); t.equal(rnd(res.saturationPressure), rnd(0.739659)); + t.equal(rnd(res.wetBulbTemp), rnd(61.189518)); inp = { dryBulbTemp: 123, @@ -240,6 +242,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(0.35)); t.equal(rnd(res.relativeHumidity), rnd(0.010235)); t.equal(rnd(res.saturationPressure), rnd(3.748742)); + t.equal(rnd(res.wetBulbTemp), rnd(62.949704)); inp = { dryBulbTemp: 70, @@ -263,6 +266,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(55.5)); t.equal(rnd(res.relativeHumidity), rnd(0.600175)); t.equal(rnd(res.saturationPressure), rnd(0.739659)); + t.equal(rnd(res.wetBulbTemp), rnd(61.19374)); inp = { dryBulbTemp: 123, @@ -288,6 +292,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(103.567304)); t.equal(rnd(res.relativeHumidity), rnd(0.574939)); t.equal(rnd(res.saturationPressure), rnd(3.748742)); + t.equal(rnd(res.wetBulbTemp), rnd(110)); inp = { dryBulbTemp: 70, @@ -312,7 +317,7 @@ test('getBaseGasDensity', function (t) { t.equal(rnd(res.dewPoint), rnd(55.566384)); t.equal(rnd(res.relativeHumidity), rnd(0.600272)); t.equal(rnd(res.saturationPressure), rnd(0.739659)); - + t.equal(rnd(res.wetBulbTemp), rnd(61.2)); }); test('getVelocityPressureData', function (t) { From 7fb6a47691c8a90c92908179ad2d4c78f65d29e0 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Wed, 13 May 2020 17:32:48 -0400 Subject: [PATCH 206/217] Cleaned up comments --- include/fans/Fan203.h | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index d46eca6a..74a60027 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -112,8 +112,6 @@ class BaseGasDensity calculateFanAttributes(inputType, relativeHumidityOrDewPoint); - //wetBulbTemp = calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, absolutePressure); //barometricPressure - /* std::ofstream fout; fout.open("debug.txt", std::ios::app); @@ -130,18 +128,6 @@ class BaseGasDensity fout << "------------------------------" << std::endl << std::endl; fout.close(); */ - /* - std::ofstream fout; - fout.open("debug.txt", std::ios::app); - fout << "Wet Bulb Temperature Test" << std::endl << std::endl; - fout << "dryBulbTemp: " << "45.00" << std::endl; - fout << "relativeHumidity: " << 50.0 / 100 << std::endl; - fout << "barometricPressure: " << "29.28" << std::endl; - fout << std::endl; - fout << "wetBulbTemp: " << calculateWetBulbTemperature(45.00, 50.0 / 100, 29.28) << std::endl; - fout << std::endl; - fout.close(); - */ } BaseGasDensity(double const dryBulbTemp, double const staticPressure, double const barometricPressure, @@ -173,19 +159,6 @@ class BaseGasDensity fout << "------------------------------" << std::endl << std::endl; fout.close(); */ - - /* - std::ofstream fout; - fout.open("debug.txt", std::ios::app); - fout << "Wet Bulb Temperature Test" << std::endl << std::endl; - fout << "dryBulbTemp: " << dryBulbTemp << std::endl; - fout << "relativeHumidity: " << relativeHumidity << std::endl; - fout << "barometricPressure: " << barometricPressure << std::endl; - fout << std::endl; - fout << "wetBulbTemp: " << calculateWetBulbTemperature(dryBulbTemp, relativeHumidity, barometricPressure) << std::endl; - fout << std::endl; - fout.close(); - */ } double getGasDensity() const From 2da6fe9aaedaf7adeb6526e943fea0d0a8dcd6ec Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 14 May 2020 09:43:45 -0400 Subject: [PATCH 207/217] Cleaned up more comments --- include/fans/Fan203.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index 74a60027..b500de59 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -217,9 +217,9 @@ class BaseGasDensity */ double calculateWetBulbTemperature(double dryBulbTemp, double relativeHumidity, double absolutePressure) const { - double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, absolutePressure, 1); // Hum_rat2 + double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, absolutePressure, 1); double wetBulbTemp = dryBulbTemp; // set initial guess - double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); // MOVE INSIDE LOOP + double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001) { From bd4e45e8e25ab0099c9f0fdcd6b1dddd97afadb9 Mon Sep 17 00:00:00 2001 From: causeyc <47064193+causeyc@users.noreply.github.com> Date: Thu, 14 May 2020 10:44:14 -0400 Subject: [PATCH 208/217] Update docker_commands.txt --- Docker/docker_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docker/docker_commands.txt b/Docker/docker_commands.txt index 7fe74228..441b9ac8 100644 --- a/Docker/docker_commands.txt +++ b/Docker/docker_commands.txt @@ -24,7 +24,7 @@ docker system prune -fa || sudo systemctl restart docker # Commands to run for building/testing/running AMO-Tools-Suite -# ------------------------------------------------------------- +# -------------------------------------------------------------- cmake -D BUILD_TESTING:BOOL=ON -D BUILD_PACKAGE:BOOL=OFF --config Debug ./ alternatively: ccmake . From 5d4a5a047bd969de68d1ee17c2e392bc47e2d4ea Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 14 May 2020 12:54:47 -0400 Subject: [PATCH 209/217] Switched from abs() to fabs() in wet bulb calculation --- include/fans/Fan203.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index b500de59..ede0a3a7 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -221,7 +221,7 @@ class BaseGasDensity double wetBulbTemp = dryBulbTemp; // set initial guess double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); - while (abs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001) + while (fabs((humidityRatioNew - humidityRatioNormal) / humidityRatioNormal) > 0.00001) { double humidityRatioNew2 = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp - 0.001, 0.24); double dw_dtwb = (humidityRatioNew - humidityRatioNew2) / 0.001; From 37c86cce25503e761ebeb7cd217ad1ed59017281 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Fri, 15 May 2020 09:36:49 -0400 Subject: [PATCH 210/217] Added comment to calculateWetBulbTemperature function --- include/fans/Fan203.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/fans/Fan203.h b/include/fans/Fan203.h index ede0a3a7..4db85d1d 100644 --- a/include/fans/Fan203.h +++ b/include/fans/Fan203.h @@ -217,6 +217,8 @@ class BaseGasDensity */ double calculateWetBulbTemperature(double dryBulbTemp, double relativeHumidity, double absolutePressure) const { + // Newton-Raphson iteration (solve to within 0.001% accuracy) + double humidityRatioNormal = calculateRatioRH(dryBulbTemp, relativeHumidity, absolutePressure, 1); double wetBulbTemp = dryBulbTemp; // set initial guess double humidityRatioNew = calculateHumidityRatioFromWetBulb(dryBulbTemp, wetBulbTemp, 0.24); From 437a774afd94a7dc1dfb37aeaaf4b6a1184a5f36 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 26 May 2020 14:55:19 -0400 Subject: [PATCH 211/217] Added Cooling Tower Calculator --- CMakeLists.txt | 7 +- binding.gyp | 48 ++++++++++++++ bindings/chillers.cpp | 11 ++++ bindings/chillers.h | 77 ++++++++++++++++++++++ include/chillers/CoolingTower.h | 110 ++++++++++++++++++++++++++++++++ src/chillers/CoolingTower.cpp | 71 +++++++++++++++++++++ tests/CoolingTower.unit.cpp | 95 +++++++++++++++++++++++++++ tests/js/chillers.js | 85 ++++++++++++++++++++++++ 8 files changed, 502 insertions(+), 2 deletions(-) create mode 100644 bindings/chillers.cpp create mode 100644 bindings/chillers.h create mode 100644 include/chillers/CoolingTower.h create mode 100644 src/chillers/CoolingTower.cpp create mode 100644 tests/CoolingTower.unit.cpp create mode 100644 tests/js/chillers.js diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d469bc2..9581eb43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,7 +196,8 @@ set(SOURCE_FILES src/calculator/util/insulation/services/ThermalResistance.cpp src/calculator/util/SteamReduction.cpp src/calculator/pump/PumpData.cpp - src/calculator/motor/MotorData.cpp) + src/calculator/motor/MotorData.cpp + src/chillers/CoolingTower.cpp) set(INCLUDE_FILES include/results/Results.h @@ -378,6 +379,7 @@ set(INCLUDE_FILES include/sqlite/PumpData.h include/calculator/motor/MotorData.h include/sqlite/MotorData.h + include/chillers/CoolingTower.h ) # Pending: PumpData calculator unit test @@ -442,7 +444,8 @@ set(TEST_FILES tests/steamapi/HeaderInput.unit.cpp tests/steamapi/OperationsInput.unit.cpp tests/steamapi/SteamModeler.unit.cpp - tests/steamapi/TurbineInput.unit.cpp) + tests/steamapi/TurbineInput.unit.cpp + tests/CoolingTower.unit.cpp) #find_package(PythonInterp 2.7 REQUIRED) #execute_process( COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/scripts/seed_database.py" "${CMAKE_DATABASE_OUTPUT_DIRECTORY}/amo_tools_suite.db") diff --git a/binding.gyp b/binding.gyp index b908e943..0f411a7e 100644 --- a/binding.gyp +++ b/binding.gyp @@ -240,6 +240,54 @@ 'cflags_cc': ['-fexceptions'] }] ] + }, + { + "target_name": "chillers", + 'include_dirs': [ + 'include', + 'include/chillers//CoolingTower.h', + #'include/calculator/util', + #'include/calculator/util/insulation', + #'include/calculator/util/insulation/pipes', + #'include/calculator/util/insulation/tanks', + #'include/calculator/util/insulation/objects', + #'include/calculator/util/insulation/services', + #'include/ssmt', + "'src/calculator/util/'+f).join(' '))\")", + #"'src/calculator/util/insulation/pipes/'+f).join(' '))\")", + #"'src/calculator/util/insulation/tanks/'+f).join(' '))\")", + #"'src/calculator/util/insulation/objects/'+f).join(' '))\")", + #"'src/calculator/util/insulation/services/'+f).join(' '))\")" + ], + "conditions": [ + [ 'OS=="mac"', { + "xcode_settings": { + 'OTHER_CPLUSPLUSFLAGS' : ['-std=c++11','-stdlib=libc++'], + 'OTHER_LDFLAGS': ['-stdlib=libc++'], + 'MACOSX_DEPLOYMENT_TARGET': '10.9', + 'CLANG_CXX_LIBRARY': 'libc++', + 'GCC_ENABLE_CPP_RTTI': 'YES', + 'GCC_ENABLE_CPP_EXCEPTIONS': "YES" + }, + }], + [ 'OS=="linux"', { + 'cflags_cc': ['-fexceptions'] + }] + ] } ] } diff --git a/bindings/chillers.cpp b/bindings/chillers.cpp new file mode 100644 index 00000000..6127f2be --- /dev/null +++ b/bindings/chillers.cpp @@ -0,0 +1,11 @@ +#include +#include "chillers.h" + +using namespace Nan; + +NAN_MODULE_INIT(InitChillers) { + Nan::Set(target, New("coolingTowerMakeupWater").ToLocalChecked(), + GetFunction(New(coolingTowerMakeupWater)).ToLocalChecked()); +} + +NODE_MODULE(chillers, InitChillers) diff --git a/bindings/chillers.h b/bindings/chillers.h new file mode 100644 index 00000000..dd3971fb --- /dev/null +++ b/bindings/chillers.h @@ -0,0 +1,77 @@ +#include "calculator.h" +#include "chillers/CoolingTower.h" + +CoolingTowerOperatingConditionsData getCoolingTowerOperatingConditionsData(Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("operatingConditionsData").ToLocalChecked(); + Local coolingTowerOperatingConditionsDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (coolingTowerOperatingConditionsDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CoolingTowerMakeupWater: getCoolingTowerOperatingConditionsData method in chillers.h: operatingConditionsData not present in object").c_str()); + } + double flowRate = GetDouble("flowRate", coolingTowerOperatingConditionsDataV8); + double coolingLoad = GetDouble("coolingLoad", coolingTowerOperatingConditionsDataV8); + int operationalHours = static_cast(GetDouble("operationalHours", coolingTowerOperatingConditionsDataV8)); + double lossCorrectionFactor = GetDouble("lossCorrectionFactor", coolingTowerOperatingConditionsDataV8); + return { + flowRate, + coolingLoad, + operationalHours, + lossCorrectionFactor}; +} + +CoolingTowerWaterConservationData getCoolingTowerWaterConservationData(Local obj, bool hasDriftEliminators) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName; + if(hasDriftEliminators) + { + getName = Nan::New("waterConservationModificationData").ToLocalChecked(); + } + else + { + getName = Nan::New("waterConservationBaselineData").ToLocalChecked(); + } + Local coolingTowerWaterConservationDataV8 = Nan::To(obj->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + if (coolingTowerWaterConservationDataV8->IsUndefined()) + { + ThrowTypeError(std::string("CoolingTowerMakeupWater: getCoolingTowerWaterConservationData method in chillers.h: neither waterConservationBaselineData nor waterConservationModificationData are present in object").c_str()); + } + int cyclesOfConcentration = static_cast(GetDouble("cyclesOfConcentration", coolingTowerWaterConservationDataV8)); + double driftLossFactor = GetDouble("driftLossFactor", coolingTowerWaterConservationDataV8); + return { + cyclesOfConcentration, + driftLossFactor}; +} + +NAN_METHOD(coolingTowerMakeupWater) +{ + inp = Nan::To(info[0]).ToLocalChecked(); + r = Nan::New(); + try + { + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New("coolingTowerMakeupWaterCalculator").ToLocalChecked(); + Local coolingTowerMakeupWaterCalculatorV8 = Nan::To(inp->Get(context, getName).ToLocalChecked()).ToLocalChecked(); + + CoolingTowerOperatingConditionsData operatingConditionsData = getCoolingTowerOperatingConditionsData(coolingTowerMakeupWaterCalculatorV8); + CoolingTowerWaterConservationData waterConservationBaselineData = getCoolingTowerWaterConservationData(coolingTowerMakeupWaterCalculatorV8, false); + CoolingTowerWaterConservationData waterConservationModificationData = getCoolingTowerWaterConservationData(coolingTowerMakeupWaterCalculatorV8, true); + + CoolingTowerMakeupWaterCalculator coolingTowerMakeupWaterCalculator(operatingConditionsData, waterConservationBaselineData, waterConservationModificationData); + CoolingTowerMakeupWaterCalculator::Output results = coolingTowerMakeupWaterCalculator.calculate(); + SetR("wcBaseline", results.wcBaseline); + SetR("wcModification", results.wcModification); + SetR("waterSavings", results.waterSavings); + } + catch (std::runtime_error const &e) + { + std::string const what = e.what(); + ThrowError(std::string("std::runtime_error thrown in coolingTowerMakeupWater - chillers.h: " + what).c_str()); + } + info.GetReturnValue().Set(r); +} \ No newline at end of file diff --git a/include/chillers/CoolingTower.h b/include/chillers/CoolingTower.h new file mode 100644 index 00000000..6dbff352 --- /dev/null +++ b/include/chillers/CoolingTower.h @@ -0,0 +1,110 @@ +/** + * @brief Contains the declarations of cooling tower classes including the getters and setters as well as the + * calculators for cooling tower makeup water. + * + * @author Colin Causey (causeyc) + * @bug No known bugs. + * + */ + +#ifndef AMO_TOOLS_SUITE_COOLING_TOWER_H +#define AMO_TOOLS_SUITE_COOLING_TOWER_H + + +class CoolingTowerOperatingConditionsData +{ + public: + /** + * @param flowRate double, water flow rate in gpm + * @param coolingLoad double, in MMBtu/h + * @param operationalHours int, number of hours cooling tower operates + * @param lossCorrectionFactor double, correction factor for evaporation loss + */ + CoolingTowerOperatingConditionsData(const double flowRate, const double coolingLoad, const int operationalHours, + const double lossCorrectionFactor) + : flowRate(flowRate), coolingLoad(coolingLoad), operationalHours(operationalHours), + lossCorrectionFactor(lossCorrectionFactor) {} + + double getFlowRate() const { return flowRate; } + double getCoolingLoad() const { return coolingLoad; } + int getOperationalHours() const { return operationalHours; } + double getLossCorrectionFactor() const { return lossCorrectionFactor; } + + void setFlowRate(double flowRate); + void setCoolingLoad(double coolingLoad); + void setOperationalHours(int operationalHours); + void setLossCorrectionFactor(double lossCorrectionFactor); + + private: + double flowRate; + double coolingLoad; + int operationalHours; + double lossCorrectionFactor = 0.85; +}; + +class CoolingTowerWaterConservationData +{ + public: + /** + * @param cyclesOfConcentration int + * @param driftLossFactor double, correction factor for drift loss + */ + CoolingTowerWaterConservationData(const int cyclesOfConcentration, const double driftLossFactor) + : cyclesOfConcentration(cyclesOfConcentration), driftLossFactor(driftLossFactor) {} + + int getCyclesOfConcentration() const { return cyclesOfConcentration; } + double getDriftLossFactor() const { return driftLossFactor; } + + void setCyclesOfConcentration(int cyclesOfConcentration); + void setDriftLossFactor(double driftLossFactor); + + private: + int cyclesOfConcentration; + double driftLossFactor; +}; + +class CoolingTowerMakeupWaterCalculator +{ + public: + struct Output + { + /** + * @param wcBaseline double, water consumption before modifications in gallons + * @param wcModification double, water consumption after modifications in gallons + * @param waterSavings double, water saved in gallons + */ + Output(double wcBaseline, double wcModification, double waterSavings) + : wcBaseline(wcBaseline), wcModification(wcModification), waterSavings(waterSavings) {} + + double wcBaseline = 0; + double wcModification = 0; + double waterSavings = 0; + }; + + CoolingTowerMakeupWaterCalculator(const CoolingTowerOperatingConditionsData &operatingConditionsData, + const CoolingTowerWaterConservationData &waterConservationBaselineData, + const CoolingTowerWaterConservationData &waterConservationModificationData) + : operatingConditionsData(operatingConditionsData), + waterConservationBaselineData(waterConservationBaselineData), + waterConservationModificationData(waterConservationModificationData) + {} + + CoolingTowerMakeupWaterCalculator::Output calculate(); + + CoolingTowerOperatingConditionsData getOperatingConditionsData() const { return operatingConditionsData; } + CoolingTowerWaterConservationData getWaterConservationBaselineData() const { return waterConservationBaselineData; } + CoolingTowerWaterConservationData getWaterConservationModificationData() const { return waterConservationModificationData; } + + void setOperatingConditionsData(CoolingTowerOperatingConditionsData operatingConditionsData); + void setWaterConservationBaselineData(CoolingTowerWaterConservationData waterConservationBaselineData); + void setWaterConservationModificationData(CoolingTowerWaterConservationData waterConservationModificationData); + + private: + CoolingTowerOperatingConditionsData operatingConditionsData; + CoolingTowerWaterConservationData waterConservationBaselineData; + CoolingTowerWaterConservationData waterConservationModificationData; +}; + + +#endif //AMO_TOOLS_SUITE_COOLING_TOWER_H + diff --git a/src/chillers/CoolingTower.cpp b/src/chillers/CoolingTower.cpp new file mode 100644 index 00000000..0a4cc770 --- /dev/null +++ b/src/chillers/CoolingTower.cpp @@ -0,0 +1,71 @@ +#include +#include +#include "chillers/CoolingTower.h" +#include + +CoolingTowerMakeupWaterCalculator::Output CoolingTowerMakeupWaterCalculator::calculate() +{ + auto const calculateWaterConsumption = [](const CoolingTowerOperatingConditionsData &operatingConditionsData, + const CoolingTowerWaterConservationData &waterConservationData) + { + double evaporationLoss, driftLoss, blowDown, waterConsumption; + + evaporationLoss = operatingConditionsData.getLossCorrectionFactor() * 0.01 * operatingConditionsData.getCoolingLoad() * 1000000 / (500 * 10); // 0.01 = evaporation loss for ideal case + + driftLoss = waterConservationData.getDriftLossFactor() * operatingConditionsData.getFlowRate(); + + blowDown = evaporationLoss / (waterConservationData.getCyclesOfConcentration() - 1); + + waterConsumption = (evaporationLoss + driftLoss + blowDown) * operatingConditionsData.getOperationalHours() * 60; + + return waterConsumption; + }; + + double wcBaseline = calculateWaterConsumption(this->operatingConditionsData, this->waterConservationBaselineData); + double wcModification = calculateWaterConsumption(this->operatingConditionsData, this->waterConservationModificationData); + double waterSavings = wcBaseline - wcModification; + + return CoolingTowerMakeupWaterCalculator::Output(wcBaseline, wcModification, waterSavings); +} + +// CoolingTowerOperatingConditionsData setters +void CoolingTowerOperatingConditionsData::setFlowRate(double flowRate) +{ + this->flowRate = flowRate; +} +void CoolingTowerOperatingConditionsData::setCoolingLoad(double coolingLoad) +{ + this->coolingLoad = coolingLoad; +} +void CoolingTowerOperatingConditionsData::setOperationalHours(int operationalHours) +{ + this->operationalHours = operationalHours; +} +void CoolingTowerOperatingConditionsData::setLossCorrectionFactor(double lossCorrectionFactor) +{ + this->lossCorrectionFactor = lossCorrectionFactor; +} + +// CoolingTowerWaterConservationData setters +void CoolingTowerWaterConservationData::setCyclesOfConcentration(int cyclesOfConcentration) +{ + this->cyclesOfConcentration = cyclesOfConcentration; +} +void CoolingTowerWaterConservationData::setDriftLossFactor(double driftLossFactor) +{ + this->driftLossFactor = driftLossFactor; +} + +// CoolingTowerMakeupWaterCalculator setters +void CoolingTowerMakeupWaterCalculator::setOperatingConditionsData(CoolingTowerOperatingConditionsData operatingConditionsData) +{ + this->operatingConditionsData = operatingConditionsData; +} +void CoolingTowerMakeupWaterCalculator::setWaterConservationBaselineData(CoolingTowerWaterConservationData waterConservationBaselineData) +{ + this->waterConservationBaselineData = waterConservationBaselineData; +} +void CoolingTowerMakeupWaterCalculator::setWaterConservationModificationData(CoolingTowerWaterConservationData waterConservationModificationData) +{ + this->waterConservationModificationData = waterConservationModificationData; +} \ No newline at end of file diff --git a/tests/CoolingTower.unit.cpp b/tests/CoolingTower.unit.cpp new file mode 100644 index 00000000..9dab7db6 --- /dev/null +++ b/tests/CoolingTower.unit.cpp @@ -0,0 +1,95 @@ +#include +#include "chillers/CoolingTower.h" +#include + +TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") +{ + auto const test = [](const std::tuple &input, + const std::tuple &ExpectedOutput) + { + double flowRate = std::get<0>(input); + double coolingLoad = std::get<1>(input); + int operationalHours = std::get<2>(input); + double lossCorrectionFactor = std::get<3>(input); + + int baselineCyclesOfConcentration = std::get<4>(input); + double baselineDriftLossFactor = std::get<5>(input); + + int modificationCyclesOfConcentration = std::get<6>(input); + double modificationDriftLossFactor = std::get<7>(input); + + CoolingTowerOperatingConditionsData operatingConditionsData(flowRate, coolingLoad, operationalHours, lossCorrectionFactor); + CoolingTowerWaterConservationData waterConservationBaselineData(baselineCyclesOfConcentration, baselineDriftLossFactor); + CoolingTowerWaterConservationData waterConservationModificationData(modificationCyclesOfConcentration, modificationDriftLossFactor); + + CoolingTowerMakeupWaterCalculator coolingTowerMakeupWaterCalculator(operatingConditionsData, waterConservationBaselineData, waterConservationModificationData); + CoolingTowerMakeupWaterCalculator::Output results = coolingTowerMakeupWaterCalculator.calculate(); + + CHECK(results.wcBaseline == std::get<0>(ExpectedOutput)); + CHECK(results.wcModification == std::get<1>(ExpectedOutput)); + CHECK(results.waterSavings == std::get<2>(ExpectedOutput)); + }; + + //Test 1 + + double flowRate = 2500; + double coolingLoad = 10.00; + int operationalHours = 1000; + double lossCorrectionFactor = 1.00; + + int baselineCyclesOfConcentration = 3; + double baselineDriftLossFactor = 0.002; + + int modificationCyclesOfConcentration = 3; + double modificationDriftLossFactor = 0.0001; + + std::tuple input1 = {flowRate, coolingLoad, operationalHours, + lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, + modificationDriftLossFactor}; + std::tuple expectedOutput1 = {2100000, 1815000, 285000}; + + test(input1, expectedOutput1); + + //Test 2 + + flowRate = 2500; + coolingLoad = 5.00; + operationalHours = 2000; + lossCorrectionFactor = 1.00; + + baselineCyclesOfConcentration = 3; + baselineDriftLossFactor = 0.002; + + modificationCyclesOfConcentration = 3; + modificationDriftLossFactor = 0.0001; + + std::tuple input2 = {flowRate, coolingLoad, operationalHours, + lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, + modificationDriftLossFactor}; + std::tuple expectedOutput2 = {2400000, 1830000, 570000}; + + test(input2, expectedOutput2); + + //Test 3 + + flowRate = 2500; + coolingLoad = 2.00; + operationalHours = 3000; + lossCorrectionFactor = 1.00; + + baselineCyclesOfConcentration = 3; + baselineDriftLossFactor = 0.002; + + modificationCyclesOfConcentration = 3; + modificationDriftLossFactor = 0.0001; + + std::tuple input3 = {flowRate, coolingLoad, operationalHours, + lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, + modificationDriftLossFactor}; + std::tuple expectedOutput3 = {1980000, 1125000, 855000}; + + test(input3, expectedOutput3); +} \ No newline at end of file diff --git a/tests/js/chillers.js b/tests/js/chillers.js new file mode 100644 index 00000000..a7e4991e --- /dev/null +++ b/tests/js/chillers.js @@ -0,0 +1,85 @@ +const test = require('tap').test + , testRoot = require('path').resolve(__dirname, '../../') + , bindings = require('bindings')({ module_root: testRoot, bindings: 'chillers' }); + +function rnd(value) { + return Number(Math.round(value + 'e' + 6) + 'e-' + 6); +} + +test('coolingTowerMakeupWater', function (t) { + t.plan(10); + t.type(bindings.coolingTowerMakeupWater, 'function'); + + // Test 1 + var inp = { + coolingTowerMakeupWaterCalculator: { + operatingConditionsData: { + flowRate: 2500, + coolingLoad: 10.00, + operationalHours: 1000, + lossCorrectionFactor: 1.00 + }, + waterConservationBaselineData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.002 + }, + waterConservationModificationData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.0001 + } + } + }; + + var res = bindings.coolingTowerMakeupWater(inp); + t.equal(rnd(res.wcBaseline), rnd(2100000), 'res.wcBaseline is ' + res.wcBaseline); + t.equal(rnd(res.wcModification), rnd(1815000), 'res.wcModification is ' + res.wcModification); + t.equal(rnd(res.waterSavings), rnd(285000), 'res.waterSavings is ' + res.waterSavings); + + // Test 2 + inp = { + coolingTowerMakeupWaterCalculator: { + operatingConditionsData: { + flowRate: 2500, + coolingLoad: 5.00, + operationalHours: 2000, + lossCorrectionFactor: 1.00 + }, + waterConservationBaselineData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.002 + }, + waterConservationModificationData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.0001 + } + } + }; + res = bindings.coolingTowerMakeupWater(inp); + t.equal(rnd(res.wcBaseline), rnd(2400000), 'res.wcBaseline is ' + res.wcBaseline); + t.equal(rnd(res.wcModification), rnd(1830000), 'res.wcModification is ' + res.wcModification); + t.equal(rnd(res.waterSavings), rnd(570000), 'res.waterSavings is ' + res.waterSavings); + + // Test 3 + inp = { + coolingTowerMakeupWaterCalculator: { + operatingConditionsData: { + flowRate: 2500, + coolingLoad: 2.00, + operationalHours: 3000, + lossCorrectionFactor: 1.00 + }, + waterConservationBaselineData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.002 + }, + waterConservationModificationData: { + cyclesOfConcentration: 3, + driftLossFactor: 0.0001 + } + } + }; + res = bindings.coolingTowerMakeupWater(inp); + t.equal(rnd(res.wcBaseline), rnd(1980000), 'res.wcBaseline is ' + res.wcBaseline); + t.equal(rnd(res.wcModification), rnd(1125000), 'res.wcModification is ' + res.wcModification); + t.equal(rnd(res.waterSavings), rnd(855000), 'res.waterSavings is ' + res.waterSavings); +}); \ No newline at end of file From 212149fa29c3710bc6e925112b9ff1ec672f0bef Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Tue, 26 May 2020 16:16:15 -0400 Subject: [PATCH 212/217] Made bindings/chillers.h no longer dependent on bindings/calculator --- binding.gyp | 2 +- bindings/chillers.h | 115 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/binding.gyp b/binding.gyp index 0f411a7e..c554664b 100644 --- a/binding.gyp +++ b/binding.gyp @@ -245,7 +245,7 @@ "target_name": "chillers", 'include_dirs': [ 'include', - 'include/chillers//CoolingTower.h', + 'include/chillers/CoolingTower.h', #'include/calculator/util', #'include/calculator/util/insulation', #'include/calculator/util/insulation/pipes', diff --git a/bindings/chillers.h b/bindings/chillers.h index dd3971fb..fcef44e7 100644 --- a/bindings/chillers.h +++ b/bindings/chillers.h @@ -1,6 +1,115 @@ -#include "calculator.h" +#ifndef AMO_TOOLS_SUITE_CHILLERS_H +#define AMO_TOOLS_SUITE_CHILLERS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +//#include "calculator.h" #include "chillers/CoolingTower.h" +using namespace Nan; +using namespace v8; + +Local inp; +Local r; + +double GetDouble(std::string const &key, Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local rObj = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (rObj->IsUndefined()) + { + ThrowTypeError(std::string("GetDouble method in calculator.h: " + key + " not present in object").c_str()); + } + return Nan::To(rObj).FromJust(); +} + +std::vector GetVector(std::string const &key, Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local arrayTmp = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (arrayTmp->IsUndefined()) + { + ThrowTypeError(std::string("GetVector method in calculator.h: " + key + " not present in object").c_str()); + } + Local jsArray = v8::Local::Cast(arrayTmp); + std::vector array; + for (unsigned int i = 0; i < jsArray->Length(); i++) + { + v8::Local jsElement = jsArray->Get(context, i).ToLocalChecked(); + double val = Nan::To(jsElement).FromJust(); + array.push_back(val); + } + return array; +} + +template +T GetEnumVal(std::string const &key, Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local rObj = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (rObj->IsUndefined()) + { + ThrowTypeError(std::string("GetEnumVal method in calculator.h: Enum value " + key + " not present in object").c_str()); + } + return static_cast(Nan::To(rObj).FromJust()); +} + +bool GetBool(std::string const &key, Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local rObj = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (rObj->IsUndefined()) + { + ThrowTypeError(std::string("GetBool method in calculator.h: Boolean value " + key + " not present in object").c_str()); + } + return rObj->BooleanValue(context).ToChecked(); +} + +std::string GetStr(std::string const &key, Local obj) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local rObj = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + if (rObj->IsUndefined()) + { + ThrowTypeError(std::string("GetStr method in calculator.h: String " + key + " not present in object").c_str()); + } + v8::String::Utf8Value s(isolate, rObj); + return std::string(*s); +} + +//NAN function for checking if an object parameter has been defined with a value +bool isDefined(Local obj, std::string const &key) +{ + v8::Isolate *isolate = v8::Isolate::GetCurrent(); + v8::Local context = isolate->GetCurrentContext(); + Local getName = Nan::New(key).ToLocalChecked(); + Local rObj = Nan::To(obj).ToLocalChecked()->Get(context, getName).ToLocalChecked(); + return !rObj->IsUndefined(); +} + +//NAN function for binding DOUBLE data to anonymous object +inline void SetR(const std::string &key, double val) +{ + Nan::Set(r, Nan::New(key).ToLocalChecked(), Nan::New(val)); +} + CoolingTowerOperatingConditionsData getCoolingTowerOperatingConditionsData(Local obj) { v8::Isolate *isolate = v8::Isolate::GetCurrent(); @@ -74,4 +183,6 @@ NAN_METHOD(coolingTowerMakeupWater) ThrowError(std::string("std::runtime_error thrown in coolingTowerMakeupWater - chillers.h: " + what).c_str()); } info.GetReturnValue().Set(r); -} \ No newline at end of file +} + +#endif //AMO_TOOLS_SUITE_CHILLERS_H \ No newline at end of file From ef4ad519009c65cc6aa42156dfa89dc217629ec4 Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 28 May 2020 11:28:33 -0400 Subject: [PATCH 213/217] Cleaned up binding.gyp --- binding.gyp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/binding.gyp b/binding.gyp index c554664b..56d612f4 100644 --- a/binding.gyp +++ b/binding.gyp @@ -246,32 +246,11 @@ 'include_dirs': [ 'include', 'include/chillers/CoolingTower.h', - #'include/calculator/util', - #'include/calculator/util/insulation', - #'include/calculator/util/insulation/pipes', - #'include/calculator/util/insulation/tanks', - #'include/calculator/util/insulation/objects', - #'include/calculator/util/insulation/services', - #'include/ssmt', "'src/calculator/util/'+f).join(' '))\")", - #"'src/calculator/util/insulation/pipes/'+f).join(' '))\")", - #"'src/calculator/util/insulation/tanks/'+f).join(' '))\")", - #"'src/calculator/util/insulation/objects/'+f).join(' '))\")", - #"'src/calculator/util/insulation/services/'+f).join(' '))\")" ], "conditions": [ [ 'OS=="mac"', { From 94ccfe213f6808e86fe8b1274e63d85d26d2f9bc Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 28 May 2020 13:04:22 -0400 Subject: [PATCH 214/217] Updated unit test --- tests/CoolingTower.unit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CoolingTower.unit.cpp b/tests/CoolingTower.unit.cpp index 9dab7db6..e510f764 100644 --- a/tests/CoolingTower.unit.cpp +++ b/tests/CoolingTower.unit.cpp @@ -47,7 +47,7 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput1 = {2100000, 1815000, 285000}; + std::tuple expectedOutput1 = {2100000.0, 1815000.0, 285000.0}; test(input1, expectedOutput1); @@ -68,7 +68,7 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput2 = {2400000, 1830000, 570000}; + std::tuple expectedOutput2 = {2400000.0, 1830000.0, 570000.0}; test(input2, expectedOutput2); @@ -89,7 +89,7 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput3 = {1980000, 1125000, 855000}; + std::tuple expectedOutput3 = {1980000.0, 1125000.0, 855000.0}; test(input3, expectedOutput3); } \ No newline at end of file From 69dfb53b148e27a90021dc967bd8f91a82d52f0f Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 28 May 2020 13:45:47 -0400 Subject: [PATCH 215/217] Updated unit test (again) --- tests/CoolingTower.unit.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/CoolingTower.unit.cpp b/tests/CoolingTower.unit.cpp index e510f764..ab3f6b89 100644 --- a/tests/CoolingTower.unit.cpp +++ b/tests/CoolingTower.unit.cpp @@ -47,7 +47,8 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput1 = {2100000.0, 1815000.0, 285000.0}; + std::tuple expectedOutput1; + expectedOutput1 = std::make_tuple(2100000.0, 1815000.0, 285000.0); test(input1, expectedOutput1); @@ -68,7 +69,8 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput2 = {2400000.0, 1830000.0, 570000.0}; + std::tuple expectedOutput2; + expectedOutput2 = std::make_tuple(2400000.0, 1830000.0, 570000.0); test(input2, expectedOutput2); @@ -89,7 +91,8 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") lossCorrectionFactor, baselineCyclesOfConcentration, baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor}; - std::tuple expectedOutput3 = {1980000.0, 1125000.0, 855000.0}; + std::tuple expectedOutput3; + expectedOutput3 = std::make_tuple(1980000.0, 1125000.0, 855000.0); test(input3, expectedOutput3); } \ No newline at end of file From c3f7d79330c97c57dc7eda06a93f69bcb88ca1ca Mon Sep 17 00:00:00 2001 From: Colin Causey Date: Thu, 28 May 2020 14:23:22 -0400 Subject: [PATCH 216/217] Updated unit test (changed tuple initialization) --- tests/CoolingTower.unit.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/CoolingTower.unit.cpp b/tests/CoolingTower.unit.cpp index ab3f6b89..7e484ee3 100644 --- a/tests/CoolingTower.unit.cpp +++ b/tests/CoolingTower.unit.cpp @@ -43,10 +43,10 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") int modificationCyclesOfConcentration = 3; double modificationDriftLossFactor = 0.0001; - std::tuple input1 = {flowRate, coolingLoad, operationalHours, - lossCorrectionFactor, baselineCyclesOfConcentration, - baselineDriftLossFactor, modificationCyclesOfConcentration, - modificationDriftLossFactor}; + std::tuple input1; + input1 = std::make_tuple(flowRate, coolingLoad, operationalHours, lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor); + std::tuple expectedOutput1; expectedOutput1 = std::make_tuple(2100000.0, 1815000.0, 285000.0); @@ -65,10 +65,10 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") modificationCyclesOfConcentration = 3; modificationDriftLossFactor = 0.0001; - std::tuple input2 = {flowRate, coolingLoad, operationalHours, - lossCorrectionFactor, baselineCyclesOfConcentration, - baselineDriftLossFactor, modificationCyclesOfConcentration, - modificationDriftLossFactor}; + std::tuple input2; + input2 = std::make_tuple(flowRate, coolingLoad, operationalHours, lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor); + std::tuple expectedOutput2; expectedOutput2 = std::make_tuple(2400000.0, 1830000.0, 570000.0); @@ -87,10 +87,10 @@ TEST_CASE("Cooling Tower Makeup Water Calculator", "[CoolingTower][Chillers]") modificationCyclesOfConcentration = 3; modificationDriftLossFactor = 0.0001; - std::tuple input3 = {flowRate, coolingLoad, operationalHours, - lossCorrectionFactor, baselineCyclesOfConcentration, - baselineDriftLossFactor, modificationCyclesOfConcentration, - modificationDriftLossFactor}; + std::tuple input3; + input3 = std::make_tuple(flowRate, coolingLoad, operationalHours, lossCorrectionFactor, baselineCyclesOfConcentration, + baselineDriftLossFactor, modificationCyclesOfConcentration, modificationDriftLossFactor); + std::tuple expectedOutput3; expectedOutput3 = std::make_tuple(1980000.0, 1125000.0, 855000.0); From 73de5ed926e95bed0fb387d6034d34fc3635251d Mon Sep 17 00:00:00 2001 From: "Accawi, Gina K" Date: Thu, 11 Jun 2020 14:11:20 -0400 Subject: [PATCH 217/217] Update version number to 0.7.0 --- Doxyfile.in | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index dd6220bc..da59fcc6 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = AMO-Tools-Suite # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = v.0.3.3 +PROJECT_NUMBER = v.0.7.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/package.json b/package.json index 33b08ddf..f0ca6087 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amo-tools-suite", - "version": "0.6.2", + "version": "0.7.0", "description": "Calculation library for the Department of Energy Advanced Manufacturing Office (DOE AMO) suite of tools", "directories": { "test": "tests"