Skip to content

Commit

Permalink
Merge pull request #157 from ORNL-AMO/fsat-add-second-calc
Browse files Browse the repository at this point in the history
Add Fan algorithms
  • Loading branch information
pshires authored Dec 7, 2017
2 parents f86212c + 9db1d55 commit f4014b8
Show file tree
Hide file tree
Showing 11 changed files with 1,304 additions and 6 deletions.
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ else (WIN32)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
endif (WIN32)

set (CMAKE_CXX_FLAGS "-Wall")

file(MAKE_DIRECTORY ${CMAKE_DATABASE_OUTPUT_DIRECTORY})

set(SOURCE_FILES
Expand Down Expand Up @@ -121,7 +123,10 @@ set(SOURCE_FILES
src/ssmt/Deaerator.cpp
src/ssmt/Header.cpp
src/ssmt/Turbine.cpp
src/calculator/util/CHP.cpp)
src/calculator/util/CHP.cpp
src/fans/Fan.cpp
src/fans/FanShaftPower.cpp
src/fans/Planar.cpp src/fans/FanCurve.cpp)

set(INCLUDE_FILES
include/psat/FieldData.h
Expand Down Expand Up @@ -199,8 +204,11 @@ set(INCLUDE_FILES
include/ssmt/FlashTank.h
include/ssmt/Deaerator.h
include/ssmt/Header.h
include/fans/Fan.h
include/fans/FanShaftPower.h
include/fans/Planar.h
include/ssmt/Turbine.h
include/calculator/util/CHP.h)
include/calculator/util/CHP.h include/fans/FanCurve.h)

set(TEST_FILES
tests/OptimalSpecificSpeedCorrection.unit.cpp
Expand Down Expand Up @@ -241,6 +249,7 @@ set(TEST_FILES
tests/Deaerator.unit.cpp
tests/Header.unit.cpp
tests/Turbine.unit.cpp
tests/Fan.unit.cpp
tests/CHP.unit.cpp)

#find_package(PythonInterp 2.7 REQUIRED)
Expand Down
115 changes: 115 additions & 0 deletions include/fans/Fan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#ifndef AMO_TOOLS_SUITE_FAN_H
#define AMO_TOOLS_SUITE_FAN_H

#include <string>
#include <unordered_map>
#include <cmath>
#include <vector>
#include <stdexcept>
#include <functional>
#include "Planar.h"
#include "FanShaftPower.h"

class FanRatedInfo;
class Planar;
class FanInletFlange;
class FanOrEvaseOutletFlange;
class FlowTraverse;
class AddlTravPlane;
class InletMstPlane;
class OutletMstPlane;

class BaseGasDensity {
public:

enum class GasType {
AIR,
STANDARDAIR,
OTHERGAS
};

enum class InputType {
DEW,
RH,
WET
};

// used for method 1
BaseGasDensity(double tdo, double pso, double pbo, double po, GasType gasType);

// TODO ensure correctness
// BaseGasDensity(double tdo, double pso, double pbo, double relativeHumidityOrDewPointTempOrHumidityRatio,
// GasType gasType, InputType inputType, double specificGravity);
//
// BaseGasDensity(double tdo, double pso, double pbo, double wetBulbTemp,
// GasType gasType, InputType inputType, double specificGravity, double cpGas);

private:

double calculateSaturationPressure(double dryBulbTemp) const;

double calculateRatioRH(double dryBulbTemp, double relativeHumidity, double barometricPressure,
double specificGravity) const;

double calculateRelativeHumidityFromWetBulb(double dryBulbTemp, double wetBulbTemp, double cpGas) const;

// dry bulb temp, reference static pressure, reference barometric pressure, gas density respectively
const double tdo, pso, pbo;

// gasDensity, specificGravity
double po, g;
const GasType gasType;

friend class PlaneData;
friend class Fan;
};


class PlaneData {
public:
PlaneData(FanInletFlange & fanInletFlange, FanOrEvaseOutletFlange & fanOrEvaseOutletFlange,
FlowTraverse & flowTraverse, std::vector<AddlTravPlane> & addlTravPlanes, InletMstPlane & inletMstPlane,
OutletMstPlane & outletMstPlane, bool variationsInPlanarBarometricPressure,
bool estimatePlaneTemp, double totalPressureLossBtwnPlanes1and4,
double totalPressureLossBtwnPlanes2and5, bool plane5upstreamOfPlane2);

private:

void establishFanInletOrOutletDensity(Planar & plane,
std::function<double (Planar const &, const double)> const & calcDensity,
double mTotal, double assumedDensity);

void calculate(BaseGasDensity const & bgd);

FanInletFlange fanInletFlange;
FanOrEvaseOutletFlange fanOrEvaseOutletFlange;
FlowTraverse flowTraverse;
std::vector<AddlTravPlane> addlTravPlanes;
InletMstPlane inletMstPlane;
OutletMstPlane outletMstPlane;

bool const variationsInPlanarBarometricPressure, estimatePlaneTemp, plane5upstreamOfPlane2;
const double totalPressureLossBtwnPlanes1and4, totalPressureLossBtwnPlanes2and5;

friend class Fan;
};


class Fan {
public:
Fan(FanRatedInfo & fanRatedInfo, PlaneData & planeData, BaseGasDensity & baseGasDensity,
FanShaftPower & fanShaftPower);

std::unordered_map<std::string, double> calculate();

private:

double calculateCompressibilityFactor(double x, double z, double isentropicExponent);

FanRatedInfo const fanRatedInfo;
PlaneData planeData;
BaseGasDensity const baseGasDensity;
FanShaftPower const fanShaftPower;
};

#endif //AMO_TOOLS_SUITE_FAN_H
159 changes: 159 additions & 0 deletions include/fans/FanCurve.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#ifndef AMO_TOOLS_SUITE_FANCURVE_H
#define AMO_TOOLS_SUITE_FANCURVE_H

#include <vector>

//class CurveConditions {
//public:
// CurveConditions(double density, double rpm, double barometricPressure, double isentropicExponent);
//
//private:
// double density, rpm, barometricPressure, isentropicExponent;
//};

enum class FanCurveType {
FanStaticPressure,
FanTotalPressure,
StaticPressureRise
};

class ResultData {
public:
ResultData(const double flow, const double pressure, const double power, const double efficiency)
: flow(flow),
pressure(pressure),
power(power),
efficiency(efficiency)
{};

const double flow, pressure, power, efficiency;
};

class FanCurveData {
public:
enum class CalculationType {
BaseCurve,
RatedPoint,
BaseOperatingPoint
};

class BaseCurve {
public:
// pressure here is pressureBox, determined by Curve Type
BaseCurve(const double flow, const double pressure, const double power)
: flow(flow),
pressure(pressure),
power(power)
{};

const double flow, pressure, power;
friend class FanCurveData;
};

class RatedPoint : public BaseCurve {
public:
// pressure here is pressureBox, determined by Curve Type
RatedPoint(const double flow, const double pressure, const double power, const double density,
const double speed, const double speedCorrected)
: BaseCurve(flow, pressure, power),
density(density),
speed(speed),
speedCorrected(speedCorrected)
{};

const double density, speed, speedCorrected;
friend class FanCurveData;
};

class BaseOperatingPoint : public RatedPoint {
public:
// pressure here is pressureBox, determined by Curve Type
BaseOperatingPoint(const double flow, const double pressure, const double power, const double density,
const double speed, const double speedCorrected, const double pressureBarometric,
const bool usePt1Factor, const double pt1 = 0)
: RatedPoint(flow, pressure, power, density, speed, speedCorrected),
pressureBarometric(pressureBarometric), usePt1Factor(usePt1Factor), pt1(pt1)
{};

const double pressureBarometric;
bool usePt1Factor;
const double pt1;
friend class FanCurveData;
};

FanCurveData(FanCurveType const curveType, std::vector<BaseCurve> baseCurveData)
: curveType(curveType),
baseCurveData(std::move(baseCurveData)),
calcType(CalculationType::BaseCurve)
{}

FanCurveData(FanCurveType const curveType, std::vector<RatedPoint> ratedPointData)
: curveType(curveType),
ratedPointData(std::move(ratedPointData)),
calcType(CalculationType::RatedPoint)
{}

FanCurveData(FanCurveType const curveType, std::vector<BaseOperatingPoint> baseOperatingPointData)
: curveType(curveType),
baseOperatingPointData(std::move(baseOperatingPointData)),
calcType(CalculationType::BaseOperatingPoint)
{}

private:
FanCurveType curveType;
std::vector<BaseCurve> baseCurveData;
std::vector<RatedPoint> ratedPointData;
std::vector<BaseOperatingPoint> baseOperatingPointData;

CalculationType calcType;

friend class FanCurve;
};

class FanCurve {
public:
FanCurve(const double density, const double densityCorrected, const double speed, const double speedCorrected,
const double pressureBarometric, const double pressureBarometricCorrected, const double pt1Factor,
const double gamma, const double gammaCorrected, const double area1, const double area2, FanCurveData data)
: density(density),
densityCorrected(densityCorrected),
speed(speed),
speedCorrected(speedCorrected),
pressureBarometric(pressureBarometric),
pressureBarometricCorrected(pressureBarometricCorrected),
pt1Factor(pt1Factor),
gamma(gamma),
gammaCorrected(gammaCorrected),
area1(area1),
area2(area2),
curveData(std::move(data))
{};

std::vector<ResultData> calculate();

private:
std::vector<ResultData> calculateBaseCurve();
std::vector<ResultData> calculateBaseOperatingPoint();
std::vector<ResultData> calculateRatedPoint();

double density, densityCorrected, speed, speedCorrected, pressureBarometric, pressureBarometricCorrected;
double pt1Factor, gamma, gammaCorrected, area1, area2;

FanCurveData curveData;
};

//class FanCurve {
//public:
// enum class FanCurveType {
// FanStaticPressure,
// FanTotalPressure,
// StaticPressureRise
// };
// FanCurve(double flow, double pressure, double horsepower, double density, double rpm, FanCurveType curveType);
//
//private:
// CurveConditions base, optimized;
// double flow, pressure, horsepower, density, rpm, isentropicExponent;
//};

#endif //AMO_TOOLS_SUITE_FANCURVE_H
53 changes: 53 additions & 0 deletions include/fans/FanShaftPower.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef AMO_TOOLS_SUITE_FANSHAFTPOWER_H
#define AMO_TOOLS_SUITE_FANSHAFTPOWER_H

class FanRatedInfo {
public:
enum class DriveType {
DIRECT,
BELT
};

// this currently does not take the field SystemDamperPosition, as it is used "only for reference purposes" as per
// page 8 in the algorithm document
FanRatedInfo(double fanDamperPosition, double fanSpeed, double motorSpeed, double nc,
double pc, double pbc, DriveType driveType);

private:
double const fanDamperPosition, fanSpeed, motorSpeed, nc, pc, pbc;
DriveType const driveType;
friend class Fan;
};

class FanShaftPower {
public:
// method 1
FanShaftPower(bool fanEquippedWithVFD, bool mainsVoltageDataAvailable, double ratedHp,
double synchronousSpeed, double npv, double fla, double hi,
double efficiencyMotor, double efficiencyVFD, double efficiencyBelt,
FanRatedInfo::DriveType driveType, double sumSEF);

// method 2
FanShaftPower(bool fanEquippedWithVFD, bool mainsVoltageDataAvailable, double ratedHp,
double synchronousSpeed, double npv, double fla, double voltage,
double amps, double powerFactorAtLoad, double efficiencyMotor,
double efficiencyVFD, double efficiencyBelt, FanRatedInfo::DriveType driveType, double sumSEF);

double getFanShaftPower() const { return hFi; }

double getSEF() const { return sumSEF; }

private:
const bool fanEquippedWithVFD, mainsVoltageDataAvailable;
const double ratedHp, synchronousSpeed, npv, fla;
const double voltage = 0, amps = 0, powerFactorAtLoad = 0;
const double hi = 0;
const double efficiencyMotor, efficiencyVFD, efficiencyBelt, powerFactor = 0;
const FanRatedInfo::DriveType driveType;
const double sumSEF;

double hMo, hFi;
};


#endif //AMO_TOOLS_SUITE_FANSHAFTPOWER_H
Loading

0 comments on commit f4014b8

Please sign in to comment.