Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | CurveIndex | |||
real(kind=r64), | intent(in) | :: | Var1 | |||
real(kind=r64), | intent(in), | optional | :: | Var2 | ||
real(kind=r64), | intent(in), | optional | :: | Var3 | ||
real(kind=r64), | intent(in), | optional | :: | Var4 |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
REAL(r64) FUNCTION PerformanceCurveObject(CurveIndex,Var1,Var2,Var3,Var4) RESULT(CurveValue)
! FUNCTION INFORMATION:
! AUTHOR Fred Buhl
! DATE WRITTEN May 2000
! MODIFIED Lixing Gu, July 2006; B. Griffith July 2006
! 22Aug2010 Craig Wray, added new curves for fan component model:
! FanPressureRise, ExponentialSkewNormal, Sigmoid, RectangularHyperbola1,
! RectangularHyperbola2, ExponentialDecay
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Given the curve index and the values of 1 or 2 independent variables,
! returns the value of an equipment performance curve.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT (IN) :: CurveIndex ! index of curve in curve array
REAL(r64), INTENT (IN) :: Var1 ! 1st independent variable
REAL(r64), INTENT (IN), OPTIONAL :: Var2 ! 2nd independent variable
REAL(r64), INTENT (IN), OPTIONAL :: Var3 ! 3rd independent variable
REAL(r64), INTENT (IN), OPTIONAL :: Var4 ! 4th independent variable
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: V1 ! 1st independent variable after limits imposed
REAL(r64) :: V2 ! 2nd independent variable after limits imposed
REAL(r64) :: V3 ! 3rd independent variable after limits imposed
REAL(r64) :: V4 ! 4th independent variable after limits imposed
REAL(r64) :: CoeffZ1 ! cpw22Aug2010 Coefficient Z1 in exponential skew normal curve
REAL(r64) :: CoeffZ2 ! cpw22Aug2010 Coefficient Z2 in exponential skew normal curve
REAL(r64) :: CoeffZ3 ! cpw22Aug2010 Coefficient Z3 in exponential skew normal curve
REAL(r64) :: CurveValueNumer ! cpw22Aug2010 Numerator in in exponential skew normal curve
REAL(r64) :: CurveValueDenom ! cpw22Aug2010 Numerator in in exponential skew normal curve
REAL(r64) :: CurveValueExp ! cpw22Aug2010 Exponential term in sigmoid curve
#ifdef nointrinsicERF
REAL(r64), EXTERNAL :: ERF
#endif
V1 = MAX(MIN(Var1,PerfCurve(CurveIndex)%Var1Max),PerfCurve(CurveIndex)%Var1Min)
IF (PRESENT(Var2)) THEN
V2 = MAX(MIN(Var2,PerfCurve(CurveIndex)%Var2Max),PerfCurve(CurveIndex)%Var2Min)
ELSE
V2 = 0.0d0
END IF
IF (PRESENT(Var3)) THEN
V3 = MAX(MIN(Var3,PerfCurve(CurveIndex)%Var3Max),PerfCurve(CurveIndex)%Var3Min)
ELSE
V3 = 0.0d0
END IF
IF (PRESENT(Var4)) THEN
V4 = MAX(MIN(Var4,PerfCurve(CurveIndex)%Var4Max),PerfCurve(CurveIndex)%Var4Min)
ELSE
V4 = 0.0d0
END IF
SELECT CASE (PerfCurve(CurveIndex)%CurveType)
CASE(Linear)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*PerfCurve(CurveIndex)%Coeff2
CASE(Quadratic)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*(PerfCurve(CurveIndex)%Coeff2 + V1*PerfCurve(CurveIndex)%Coeff3)
CASE(QuadLinear)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*PerfCurve(CurveIndex)%Coeff2 + V2*PerfCurve(CurveIndex)%Coeff3 &
+ V3*PerfCurve(CurveIndex)%Coeff4 + V4*PerfCurve(CurveIndex)%Coeff5
CASE(Cubic)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*(PerfCurve(CurveIndex)%Coeff2 + &
V1*(PerfCurve(CurveIndex)%Coeff3 + V1*PerfCurve(CurveIndex)%Coeff4))
CASE(Quartic)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + &
V1*(PerfCurve(CurveIndex)%Coeff2 + &
V1*(PerfCurve(CurveIndex)%Coeff3 + &
V1*(PerfCurve(CurveIndex)%Coeff4 + &
V1*PerfCurve(CurveIndex)%Coeff5)))
CASE(Biquadratic)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*(PerfCurve(CurveIndex)%Coeff2 + V1*PerfCurve(CurveIndex)%Coeff3) &
+ V2*(PerfCurve(CurveIndex)%Coeff4 + V2*PerfCurve(CurveIndex)%Coeff5) &
+ V1*V2*PerfCurve(CurveIndex)%Coeff6
CASE(QuadraticLinear)
CurveValue = (PerfCurve(CurveIndex)%Coeff1 + V1*(PerfCurve(CurveIndex)%Coeff2 + V1*PerfCurve(CurveIndex)%Coeff3)) &
+(PerfCurve(CurveIndex)%Coeff4 + V1*(PerfCurve(CurveIndex)%Coeff5 + V1*PerfCurve(CurveIndex)%Coeff6))*V2
CASE(Bicubic)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + V1*PerfCurve(CurveIndex)%Coeff2 + V1*V1*PerfCurve(CurveIndex)%Coeff3 &
+ V2*PerfCurve(CurveIndex)%Coeff4 + V2*V2*PerfCurve(CurveIndex)%Coeff5 + V1*V2*PerfCurve(CurveIndex)%Coeff6 &
+ V1**3*PerfCurve(CurveIndex)%Coeff7 + V2**3*PerfCurve(CurveIndex)%Coeff8 &
+ V1*V1*V2*PerfCurve(CurveIndex)%Coeff9+ V1*V2*V2*PerfCurve(CurveIndex)%Coeff10
CASE(TriQuadratic)
CurveValue = PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA0 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA1 * V1**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA2 * V1 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA3 * V2**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA4 * V2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA5 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA6 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA7 * V1**2 * V2**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA8 * V1 * V2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA9 * V1 * V2**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA10 * V1**2 * V2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA11 * V1**2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA12 * V1 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA13 * V1 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA14 * V1**2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA15 * V2**2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA16 * V2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA17 * V2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA18 * V2**2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA19 * V1**2 * V2**2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA20 * V1**2 * V2**2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA21 * V1**2 * V2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA22 * V1 * V2**2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA23 * V1**2 * V2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA24 * V1 * V2**2 * V3 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA25 * V1 * V2 * V3**2 &
+ PerfCurve(Curveindex)%Tri2ndOrder(1)%CoeffA26 * V1 * V2 * V3
CASE(Exponent)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + PerfCurve(CurveIndex)%Coeff2 * (V1**PerfCurve(CurveIndex)%Coeff3)
!cpw22Aug2010 Added Fan Pressure Rise curve
CASE(FanPressureRise)
CurveValue = PerfCurve(CurveIndex)%Coeff1 * V1**2 + PerfCurve(CurveIndex)%Coeff2 * V1 &
+ PerfCurve(CurveIndex)%Coeff3 * V1 * SQRT(V2) + PerfCurve(CurveIndex)%Coeff4 * V2
!cpw22Aug2010 Added Exponential Skew Normal curve
CASE(ExponentialSkewNormal)
CoeffZ1 = (V1 - PerfCurve(CurveIndex)%Coeff1) / PerfCurve(CurveIndex)%Coeff2
CoeffZ2 = (PerfCurve(CurveIndex)%Coeff4 * V1 * EXP(PerfCurve(CurveIndex)%Coeff3 * V1) &
- PerfCurve(CurveIndex)%Coeff1) / PerfCurve(CurveIndex)%Coeff2
CoeffZ3 = -PerfCurve(CurveIndex)%Coeff1 / PerfCurve(CurveIndex)%Coeff2
! CurveValueNumer = EXP(-0.5d0 * CoeffZ1**2) * (1.d0 + SIGN(1.0d0,CoeffZ2) * ErfFunction(ABS(CoeffZ2)/SQRT(2.0d0)))
! CurveValueDenom = EXP(-0.5d0 * CoeffZ3**2) * (1.d0 + SIGN(1.0d0,CoeffZ3) * ErfFunction(ABS(CoeffZ3)/SQRT(2.0d0)))
CurveValueNumer = EXP(-0.5d0 * CoeffZ1**2) * (1.d0 + SIGN(1.0d0,CoeffZ2) * ERF(ABS(CoeffZ2)/SQRT(2.0d0)))
CurveValueDenom = EXP(-0.5d0 * CoeffZ3**2) * (1.d0 + SIGN(1.0d0,CoeffZ3) * ERF(ABS(CoeffZ3)/SQRT(2.0d0)))
CurveValue = CurveValueNumer / CurveValueDenom
!cpw22Aug2010 Added Sigmoid curve
CASE(Sigmoid)
CurveValueExp = EXP((PerfCurve(CurveIndex)%Coeff3 - V1) / PerfCurve(CurveIndex)%Coeff4)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + PerfCurve(CurveIndex)%Coeff2 &
/ ((1.0d0 + CurveValueExp)**PerfCurve(CurveIndex)%Coeff5)
!cpw22Aug2010 Added Rectangular Hyperbola Type 1 curve
CASE(RectangularHyperbola1)
CurveValueNumer = PerfCurve(CurveIndex)%Coeff1 * V1
CurveValueDenom = PerfCurve(CurveIndex)%Coeff2 + V1
CurveValue = (CurveValueNumer / CurveValueDenom) + PerfCurve(CurveIndex)%Coeff3
!cpw22Aug2010 Added Rectangular Hyperbola Type 2 curve
CASE(RectangularHyperbola2)
CurveValueNumer = PerfCurve(CurveIndex)%Coeff1 * V1
CurveValueDenom = PerfCurve(CurveIndex)%Coeff2 + V1
CurveValue = (CurveValueNumer / CurveValueDenom) + (PerfCurve(CurveIndex)%Coeff3 * V1)
!cpw22Aug2010 Added Exponential Decay curve
CASE(ExponentialDecay)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + PerfCurve(CurveIndex)%Coeff2 &
* EXP(PerfCurve(CurveIndex)%Coeff3 * V1)
!ykt Jul 2011 Added Double Exponential Decay curve
CASE(DoubleExponentialDecay)
CurveValue = PerfCurve(CurveIndex)%Coeff1 + PerfCurve(CurveIndex)%Coeff2 &
* EXP(PerfCurve(CurveIndex)%Coeff3 * V1)+PerfCurve(CurveIndex)%Coeff4*EXP(PerfCurve(CurveIndex)%Coeff5 * V1)
CASE DEFAULT
CurveValue = 0.0d0
END SELECT
IF(PerfCurve(CurveIndex)%CurveMinPresent) CurveValue = MAX(CurveValue , PerfCurve(CurveIndex)%CurveMin)
IF(PerfCurve(CurveIndex)%CurveMaxPresent) CurveValue = MIN(CurveValue , PerfCurve(CurveIndex)%CurveMax)
RETURN
END FUNCTION PerformanceCurveObject