| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(in) | :: | SpeedRatio | |||
| real(kind=r64), | intent(in), | optional | DIMENSION(:) | :: | Par | 
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 VSHPSpeedResidual(SpeedRatio,Par)
          ! FUNCTION INFORMATION:
          !       AUTHOR         Bo Shen, , based on HVACMultiSpeedHeatPump:MSHPVarSpeedgResidual
          !       DATE WRITTEN   March, 2012
          !       MODIFIED       na
          !       RE-ENGINEERED  na
          ! PURPOSE OF THIS FUNCTION:
          !  Calculates residual function ((ActualOutput - QZnReq)/QZnReq)
          !  MSHP output depends on the part load ratio which is being varied to zero the residual.
          ! METHODOLOGY EMPLOYED:
          !  Calls CalcMSHeatPump to get ActualOutput at the given speed ratio (partload ratio for high speed)
          !  and calculates the residual as defined above
          ! REFERENCES:
          ! USE STATEMENTS:
          ! na
  IMPLICIT NONE    ! Enforce explicit typing of all variables in this routine
          ! SUBROUTINE ARGUMENT DEFINITIONS:
  REAL(r64), INTENT(IN)   :: SpeedRatio ! compressor cycling ratio (1.0 is continuous, 0.0 is off)
  REAL(r64), INTENT(IN), DIMENSION(:), OPTIONAL :: Par ! par(1) = MSHPNum
                                                  ! par(2) = Zone Num
                                                  ! par(3) = FirstHVACIteration
                                                  ! par(4) = OpMode
                                                  ! par(5) = QZnReq
                                                  ! par(6) = OnOffAirFlowRatio
                                                  ! par(7) = SupHeaterLoad
                                                  ! par(8) = SpeedNum
                                                  ! par(9) = CompOp
                                                  ! par(10) = 1.0 to meet sensible load
          ! FUNCTION PARAMETER DEFINITIONS:
          !  na
          ! INTERFACE BLOCK SPECIFICATIONS
          !  na
          ! DERIVED TYPE DEFINITIONS
          !  na
          ! FUNCTION LOCAL VARIABLE DECLARATIONS:
  LOGICAL :: HXUnitOn             ! flag to enable heat exchanger
  INTEGER :: PTUnitNum      ! MSHP index
  INTEGER :: ZoneNum            ! Zone index
  LOGICAL :: FirstHVACIteration ! FirstHVACIteration flag
  INTEGER :: OpMode             ! Compressor operating mode
  REAL(r64)    :: QZnReq             ! zone load (W)
  REAL(r64)    :: QZnLat             ! zone latent load (W)
  REAL(r64)    :: OnOffAirFlowRatio  ! ratio of compressor ON airflow to average airflow over timestep
  REAL(r64)    :: ZoneSensLoadMet       ! delivered sensible capacity of MSHP
  REAL(r64)    :: ZoneLatLoadMet       ! delivered latent capacity of MSHP
  REAL(r64)    :: LoadToBeMet      ! sensible or latent load to be met
  REAL(r64)    :: SupHeaterLoad      ! Supplemental heater load
  REAL(r64)    :: ResScale        ! Residual scale
  INTEGER :: SpeedNum           ! Speed number
  INTEGER :: CompOp             ! compressor operation; 1=on, 0=off
  PTUnitNum = INT(Par(1))
  ZoneNum = INT(Par(2))
  ! FirstHVACIteration is a logical, Par is REAL(r64), so make 1.0=TRUE and 0.0=FALSE
  IF(Par(3) .EQ. 1.0d0)THEN
    FirstHVACIteration = .TRUE.
  ELSE
    FirstHVACIteration = .FALSE.
  END IF
  OpMode = INT(Par(4))
  QZnReq = 0.0d0
  QZnLat = 0.0d0
  LoadToBeMet = Par(5)
  IF(Par(10) .EQ. 1.0d0) THEN
    QZnReq = Par(5)
  ELSE
    QZnLat = Par(5)
  END IF
  OnOffAirFlowRatio = Par(6)
  SupHeaterLoad     = Par(7)
  SpeedNum     = INT(Par(8))
  CompOp = INT(Par(9))
  IF(Par(11) > 0.0d0)THEN
    HXUnitOn = .TRUE.
  ELSE
   HXUnitOn = .FALSE.
  END IF
  Call CalcVarSpeedHeatPump(PTUnitNum, ZoneNum, FirstHVACIteration,CompOp,SpeedNum,  &
                          SpeedRatio,1.0d0,ZoneSensLoadMet, ZoneLatLoadMet, &
                          QZnReq, QZnLat, OnOffAirFlowRatio,SupHeaterLoad, HXUnitOn)
  ResScale = abs(LoadToBeMet)
  IF (ResScale < 100.0d0) THEN
    ResScale = 100.0d0
  END IF
    ! Calculate residual based on output calculation flag
  IF(Par(10) .EQ. 1.0d0) THEN
    VSHPSpeedResidual = (ZoneSensLoadMet - LoadToBeMet)/ResScale
  ELSE
    VSHPSpeedResidual = (ZoneLatLoadMet - LoadToBeMet)/ResScale
  END IF
  RETURN
END FUNCTION VSHPSpeedResidual