PlantValves.f90 Source File

This File Depends On

sourcefile~~plantvalves.f90~~EfferentGraph sourcefile~plantvalves.f90 PlantValves.f90 sourcefile~dataloopnode.f90 DataLoopNode.f90 sourcefile~dataloopnode.f90->sourcefile~plantvalves.f90 sourcefile~dataplant.f90 DataPlant.f90 sourcefile~dataloopnode.f90->sourcefile~dataplant.f90 sourcefile~nodeinputmanager.f90 NodeInputManager.f90 sourcefile~dataloopnode.f90->sourcefile~nodeinputmanager.f90 sourcefile~plantutilities.f90 PlantUtilities.f90 sourcefile~dataloopnode.f90->sourcefile~plantutilities.f90 sourcefile~branchnodeconnections.f90 BranchNodeConnections.f90 sourcefile~dataloopnode.f90->sourcefile~branchnodeconnections.f90 sourcefile~branchinputmanager.f90 BranchInputManager.f90 sourcefile~dataloopnode.f90->sourcefile~branchinputmanager.f90 sourcefile~curvemanager.f90 CurveManager.f90 sourcefile~dataloopnode.f90->sourcefile~curvemanager.f90 sourcefile~general.f90 General.f90 sourcefile~general.f90->sourcefile~plantvalves.f90 sourcefile~general.f90->sourcefile~dataplant.f90 sourcefile~general.f90->sourcefile~nodeinputmanager.f90 sourcefile~general.f90->sourcefile~plantutilities.f90 sourcefile~general.f90->sourcefile~branchnodeconnections.f90 sourcefile~general.f90->sourcefile~branchinputmanager.f90 sourcefile~general.f90->sourcefile~curvemanager.f90 sourcefile~schedulemanager.f90 ScheduleManager.f90 sourcefile~general.f90->sourcefile~schedulemanager.f90 sourcefile~outputprocessor.f90 OutputProcessor.f90 sourcefile~general.f90->sourcefile~outputprocessor.f90 sourcefile~fluidproperties.f90 FluidProperties.f90 sourcefile~general.f90->sourcefile~fluidproperties.f90 sourcefile~psychroutines.f90 PsychRoutines.f90 sourcefile~general.f90->sourcefile~psychroutines.f90 sourcefile~dataenvironment.f90 DataEnvironment.f90 sourcefile~general.f90->sourcefile~dataenvironment.f90 sourcefile~sqlitefortranroutines.f90 SQLiteFortranRoutines.f90 sourcefile~general.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~dataheatbalance.f90 DataHeatBalance.f90 sourcefile~general.f90->sourcefile~dataheatbalance.f90 sourcefile~datahvacglobals.f90 DataHVACGlobals.f90 sourcefile~datahvacglobals.f90->sourcefile~plantvalves.f90 sourcefile~datahvacglobals.f90->sourcefile~general.f90 sourcefile~datahvacglobals.f90->sourcefile~branchinputmanager.f90 sourcefile~dataplant.f90->sourcefile~plantvalves.f90 sourcefile~dataplant.f90->sourcefile~plantutilities.f90 sourcefile~dataprecisionglobals.f90 DataPrecisionGlobals.f90 sourcefile~dataprecisionglobals.f90->sourcefile~plantvalves.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataloopnode.f90 sourcefile~dataprecisionglobals.f90->sourcefile~general.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datahvacglobals.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataplant.f90 sourcefile~databranchairloopplant.f90 DataBranchAirLoopPlant.f90 sourcefile~dataprecisionglobals.f90->sourcefile~databranchairloopplant.f90 sourcefile~dataglobals.f90 DataGlobals.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataglobals.f90 sourcefile~dataipshortcuts.f90 DataIPShortCuts.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataipshortcuts.f90 sourcefile~dataprecisionglobals.f90->sourcefile~nodeinputmanager.f90 sourcefile~dataprecisionglobals.f90->sourcefile~plantutilities.f90 sourcefile~datainterfaces.f90 DataInterfaces.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datainterfaces.f90 sourcefile~inputprocessor.f90 InputProcessor.f90 sourcefile~dataprecisionglobals.f90->sourcefile~inputprocessor.f90 sourcefile~datasurfaces.f90 DataSurfaces.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datasurfaces.f90 sourcefile~dataruntimelanguage.f90 DataRuntimeLanguage.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataruntimelanguage.f90 sourcefile~datavectortypes.f90 DataVectorTypes.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datavectortypes.f90 sourcefile~databsdfwindow.f90 DataBSDFWindow.f90 sourcefile~dataprecisionglobals.f90->sourcefile~databsdfwindow.f90 sourcefile~dataprecisionglobals.f90->sourcefile~branchinputmanager.f90 sourcefile~datasizing.f90 DataSizing.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datasizing.f90 sourcefile~dataprecisionglobals.f90->sourcefile~curvemanager.f90 sourcefile~dataerrortracking.f90 DataErrorTracking.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataerrortracking.f90 sourcefile~datasystemvariables.f90 DataSystemVariables.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datasystemvariables.f90 sourcefile~dataprecisionglobals.f90->sourcefile~schedulemanager.f90 sourcefile~dataprecisionglobals.f90->sourcefile~outputprocessor.f90 sourcefile~dataprecisionglobals.f90->sourcefile~fluidproperties.f90 sourcefile~datacontaminantbalance.f90 DataContaminantBalance.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datacontaminantbalance.f90 sourcefile~dataprecisionglobals.f90->sourcefile~psychroutines.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataenvironment.f90 sourcefile~dataprecisionglobals.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~outputreportpredefined.f90 OutputReportPredefined.f90 sourcefile~dataprecisionglobals.f90->sourcefile~outputreportpredefined.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataheatbalance.f90 sourcefile~dataroomair.f90 DataRoomAir.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataroomair.f90 sourcefile~datacomplexfenestration.f90 DataComplexFenestration.f90 sourcefile~dataprecisionglobals.f90->sourcefile~datacomplexfenestration.f90 sourcefile~dataequivalentlayerwindow.f90 DataEquivalentLayerWindow.f90 sourcefile~dataprecisionglobals.f90->sourcefile~dataequivalentlayerwindow.f90 sourcefile~databranchairloopplant.f90->sourcefile~plantvalves.f90 sourcefile~databranchairloopplant.f90->sourcefile~plantutilities.f90 sourcefile~databranchairloopplant.f90->sourcefile~branchinputmanager.f90 sourcefile~databranchairloopplant.f90->sourcefile~curvemanager.f90 sourcefile~dataglobals.f90->sourcefile~plantvalves.f90 sourcefile~dataglobals.f90->sourcefile~dataloopnode.f90 sourcefile~dataglobals.f90->sourcefile~general.f90 sourcefile~dataglobals.f90->sourcefile~datahvacglobals.f90 sourcefile~dataglobals.f90->sourcefile~dataplant.f90 sourcefile~dataglobals.f90->sourcefile~databranchairloopplant.f90 sourcefile~dataglobals.f90->sourcefile~dataipshortcuts.f90 sourcefile~dataglobals.f90->sourcefile~nodeinputmanager.f90 sourcefile~dataglobals.f90->sourcefile~plantutilities.f90 sourcefile~dataglobals.f90->sourcefile~branchnodeconnections.f90 sourcefile~dataglobals.f90->sourcefile~inputprocessor.f90 sourcefile~dataglobals.f90->sourcefile~datasurfaces.f90 sourcefile~dataglobals.f90->sourcefile~dataruntimelanguage.f90 sourcefile~dataglobals.f90->sourcefile~databsdfwindow.f90 sourcefile~dataglobals.f90->sourcefile~branchinputmanager.f90 sourcefile~dataglobals.f90->sourcefile~datasizing.f90 sourcefile~dataglobals.f90->sourcefile~curvemanager.f90 sourcefile~dataglobals.f90->sourcefile~schedulemanager.f90 sourcefile~dataglobals.f90->sourcefile~outputprocessor.f90 sourcefile~dataglobals.f90->sourcefile~fluidproperties.f90 sourcefile~dataglobals.f90->sourcefile~datacontaminantbalance.f90 sourcefile~dataglobals.f90->sourcefile~psychroutines.f90 sourcefile~dataglobals.f90->sourcefile~dataenvironment.f90 sourcefile~sortandstringutilities.f90 SortAndStringUtilities.f90 sourcefile~dataglobals.f90->sourcefile~sortandstringutilities.f90 sourcefile~dataoutputs.f90 DataOutputs.f90 sourcefile~dataglobals.f90->sourcefile~dataoutputs.f90 sourcefile~dataglobals.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~dataglobalconstants.f90 DataGlobalConstants.f90 sourcefile~dataglobals.f90->sourcefile~dataglobalconstants.f90 sourcefile~dataglobals.f90->sourcefile~outputreportpredefined.f90 sourcefile~dataglobals.f90->sourcefile~dataheatbalance.f90 sourcefile~dataglobals.f90->sourcefile~dataroomair.f90 sourcefile~dataglobals.f90->sourcefile~datacomplexfenestration.f90 sourcefile~dataglobals.f90->sourcefile~dataequivalentlayerwindow.f90 sourcefile~databranchnodeconnections.f90 DataBranchNodeConnections.f90 sourcefile~dataglobals.f90->sourcefile~databranchnodeconnections.f90 sourcefile~dataipshortcuts.f90->sourcefile~plantvalves.f90 sourcefile~dataipshortcuts.f90->sourcefile~general.f90 sourcefile~dataipshortcuts.f90->sourcefile~inputprocessor.f90 sourcefile~dataipshortcuts.f90->sourcefile~curvemanager.f90 sourcefile~dataipshortcuts.f90->sourcefile~schedulemanager.f90 sourcefile~dataipshortcuts.f90->sourcefile~outputprocessor.f90 sourcefile~nodeinputmanager.f90->sourcefile~plantvalves.f90 sourcefile~nodeinputmanager.f90->sourcefile~branchinputmanager.f90 sourcefile~plantutilities.f90->sourcefile~plantvalves.f90 sourcefile~datainterfaces.f90->sourcefile~plantvalves.f90 sourcefile~datainterfaces.f90->sourcefile~general.f90 sourcefile~datainterfaces.f90->sourcefile~dataplant.f90 sourcefile~datainterfaces.f90->sourcefile~nodeinputmanager.f90 sourcefile~datainterfaces.f90->sourcefile~plantutilities.f90 sourcefile~datainterfaces.f90->sourcefile~branchnodeconnections.f90 sourcefile~datainterfaces.f90->sourcefile~inputprocessor.f90 sourcefile~datainterfaces.f90->sourcefile~dataruntimelanguage.f90 sourcefile~datainterfaces.f90->sourcefile~branchinputmanager.f90 sourcefile~datainterfaces.f90->sourcefile~curvemanager.f90 sourcefile~datainterfaces.f90->sourcefile~schedulemanager.f90 sourcefile~datainterfaces.f90->sourcefile~outputprocessor.f90 sourcefile~datainterfaces.f90->sourcefile~fluidproperties.f90 sourcefile~datainterfaces.f90->sourcefile~psychroutines.f90 sourcefile~datainterfaces.f90->sourcefile~dataenvironment.f90 sourcefile~datainterfaces.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~datainterfaces.f90->sourcefile~dataheatbalance.f90 sourcefile~branchnodeconnections.f90->sourcefile~plantvalves.f90 sourcefile~branchnodeconnections.f90->sourcefile~nodeinputmanager.f90 sourcefile~branchnodeconnections.f90->sourcefile~branchinputmanager.f90 sourcefile~inputprocessor.f90->sourcefile~plantvalves.f90 sourcefile~inputprocessor.f90->sourcefile~general.f90 sourcefile~inputprocessor.f90->sourcefile~dataplant.f90 sourcefile~inputprocessor.f90->sourcefile~nodeinputmanager.f90 sourcefile~inputprocessor.f90->sourcefile~branchnodeconnections.f90 sourcefile~inputprocessor.f90->sourcefile~branchinputmanager.f90 sourcefile~inputprocessor.f90->sourcefile~curvemanager.f90 sourcefile~inputprocessor.f90->sourcefile~schedulemanager.f90 sourcefile~inputprocessor.f90->sourcefile~outputprocessor.f90 sourcefile~inputprocessor.f90->sourcefile~fluidproperties.f90 sourcefile~inputprocessor.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~inputprocessor.f90->sourcefile~dataglobalconstants.f90 sourcefile~inputprocessor.f90->sourcefile~dataheatbalance.f90 sourcefile~datasurfaces.f90->sourcefile~general.f90 sourcefile~datasurfaces.f90->sourcefile~datacontaminantbalance.f90 sourcefile~datasurfaces.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~datasurfaces.f90->sourcefile~dataheatbalance.f90 sourcefile~dataruntimelanguage.f90->sourcefile~general.f90 sourcefile~datastringglobals.f90 DataStringGlobals.f90 sourcefile~datastringglobals.f90->sourcefile~general.f90 sourcefile~datastringglobals.f90->sourcefile~inputprocessor.f90 sourcefile~datastringglobals.f90->sourcefile~datasystemvariables.f90 sourcefile~datastringglobals.f90->sourcefile~schedulemanager.f90 sourcefile~datastringglobals.f90->sourcefile~outputprocessor.f90 sourcefile~datastringglobals.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~datavectortypes.f90->sourcefile~datasurfaces.f90 sourcefile~datavectortypes.f90->sourcefile~databsdfwindow.f90 sourcefile~datavectortypes.f90->sourcefile~dataheatbalance.f90 sourcefile~databsdfwindow.f90->sourcefile~datasurfaces.f90 sourcefile~databsdfwindow.f90->sourcefile~dataheatbalance.f90 sourcefile~branchinputmanager.f90->sourcefile~dataplant.f90 sourcefile~datasizing.f90->sourcefile~dataplant.f90 sourcefile~datasizing.f90->sourcefile~plantutilities.f90 sourcefile~datasizing.f90->sourcefile~inputprocessor.f90 sourcefile~datasizing.f90->sourcefile~branchinputmanager.f90 sourcefile~curvemanager.f90->sourcefile~branchinputmanager.f90 sourcefile~dataerrortracking.f90->sourcefile~nodeinputmanager.f90 sourcefile~dataerrortracking.f90->sourcefile~branchinputmanager.f90 sourcefile~datasystemvariables.f90->sourcefile~inputprocessor.f90 sourcefile~datasystemvariables.f90->sourcefile~curvemanager.f90 sourcefile~datasystemvariables.f90->sourcefile~schedulemanager.f90 sourcefile~datasystemvariables.f90->sourcefile~outputprocessor.f90 sourcefile~datasystemvariables.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~schedulemanager.f90->sourcefile~nodeinputmanager.f90 sourcefile~schedulemanager.f90->sourcefile~outputprocessor.f90 sourcefile~schedulemanager.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~outputprocessor.f90->sourcefile~nodeinputmanager.f90 sourcefile~fluidproperties.f90->sourcefile~nodeinputmanager.f90 sourcefile~fluidproperties.f90->sourcefile~plantutilities.f90 sourcefile~datacontaminantbalance.f90->sourcefile~nodeinputmanager.f90 sourcefile~psychroutines.f90->sourcefile~nodeinputmanager.f90 sourcefile~dataenvironment.f90->sourcefile~nodeinputmanager.f90 sourcefile~dataenvironment.f90->sourcefile~schedulemanager.f90 sourcefile~dataenvironment.f90->sourcefile~outputprocessor.f90 sourcefile~dataenvironment.f90->sourcefile~psychroutines.f90 sourcefile~dataenvironment.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~dataenvironment.f90->sourcefile~dataheatbalance.f90 sourcefile~sortandstringutilities.f90->sourcefile~inputprocessor.f90 sourcefile~sortandstringutilities.f90->sourcefile~outputprocessor.f90 sourcefile~dataoutputs.f90->sourcefile~inputprocessor.f90 sourcefile~dataoutputs.f90->sourcefile~outputprocessor.f90 sourcefile~sqlitefortranroutines.f90->sourcefile~outputprocessor.f90 sourcefile~dataglobalconstants.f90->sourcefile~outputprocessor.f90 sourcefile~outputreportpredefined.f90->sourcefile~outputprocessor.f90 sourcefile~dataheatbalance.f90->sourcefile~outputprocessor.f90 sourcefile~dataheatbalance.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~dataroomair.f90->sourcefile~sqlitefortranroutines.f90 sourcefile~datacomplexfenestration.f90->sourcefile~dataheatbalance.f90 sourcefile~dataequivalentlayerwindow.f90->sourcefile~dataheatbalance.f90 sourcefile~databranchnodeconnections.f90->sourcefile~branchnodeconnections.f90
Help

Files Dependent On This One

sourcefile~~plantvalves.f90~~AfferentGraph sourcefile~plantvalves.f90 PlantValves.f90 sourcefile~plantloopequipment.f90 PlantLoopEquipment.f90 sourcefile~plantvalves.f90->sourcefile~plantloopequipment.f90 sourcefile~plantmanager.f90 PlantManager.f90 sourcefile~plantloopequipment.f90->sourcefile~plantmanager.f90 sourcefile~plantloopsolver.f90 PlantLoopSolver.f90 sourcefile~plantloopequipment.f90->sourcefile~plantloopsolver.f90 sourcefile~simulationmanager.f90 SimulationManager.f90 sourcefile~plantmanager.f90->sourcefile~simulationmanager.f90 sourcefile~utilityroutines.f90 UtilityRoutines.f90 sourcefile~plantmanager.f90->sourcefile~utilityroutines.f90 sourcefile~hvacmanager.f90 HVACManager.f90 sourcefile~plantmanager.f90->sourcefile~hvacmanager.f90 sourcefile~plantloopsolver.f90->sourcefile~plantmanager.f90 sourcefile~simulationmanager.f90->sourcefile~utilityroutines.f90 sourcefile~energyplus.f90 EnergyPlus.f90 sourcefile~simulationmanager.f90->sourcefile~energyplus.f90 sourcefile~hvacmanager.f90->sourcefile~simulationmanager.f90 sourcefile~heatbalanceairmanager.f90 HeatBalanceAirManager.f90 sourcefile~hvacmanager.f90->sourcefile~heatbalanceairmanager.f90 sourcefile~heatbalanceairmanager.f90->sourcefile~simulationmanager.f90 sourcefile~heatbalancesurfacemanager.f90 HeatBalanceSurfaceManager.f90 sourcefile~heatbalanceairmanager.f90->sourcefile~heatbalancesurfacemanager.f90 sourcefile~heatbalancesurfacemanager.f90->sourcefile~simulationmanager.f90 sourcefile~heatbalancemanager.f90 HeatBalanceManager.f90 sourcefile~heatbalancesurfacemanager.f90->sourcefile~heatbalancemanager.f90 sourcefile~heatbalancemanager.f90->sourcefile~simulationmanager.f90 sourcefile~sizingmanager.f90 SizingManager.f90 sourcefile~heatbalancemanager.f90->sourcefile~sizingmanager.f90 sourcefile~sizingmanager.f90->sourcefile~simulationmanager.f90
Help

Source Code


Source Code

MODULE PlantValves

          ! Module containing the routines dealing with the <module_name>

          ! MODULE INFORMATION:
          !       AUTHOR         B. Griffith
          !       DATE WRITTEN   Jan, 2006
          !       MODIFIED       Nov 2010, B. Griffith, plant upgrades
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS MODULE:
          ! Collect "valve" type models for Plant loops

          ! METHODOLOGY EMPLOYED:
          !

          ! REFERENCES:
          ! na

          ! OTHER NOTES:
          ! na

          ! USE STATEMENTS:
          ! <use statements for data only modules>
USE DataPrecisionGlobals
USE DataLoopNode
USE DataGlobals, ONLY: MaxNameLength
USE DataInterfaces, ONLY: ShowWarningError, ShowSevereError, ShowFatalError
USE General, ONLY: TrimSigDigits

          ! <use statements for access to subroutines in other modules>

IMPLICIT NONE ! Enforce explicit typing of all variables

PRIVATE ! Everything private unless explicitly made public

          ! MODULE PARAMETER DEFINITIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
TYPE TemperValveData
  ! user input data
    CHARACTER(len=MaxNameLength) :: Name     =' '   ! User identifier
    INTEGER :: PltInletNodeNum      = 0   ! Node number on the inlet side of the plant
    INTEGER :: PltOutletNodeNum     = 0   ! Node number on the outlet side of the plant
    INTEGER :: PltStream2NodeNum    = 0   ! Node number on the outlet side of the second stream
    INTEGER :: PltSetPointNodeNum   = 0   ! Node number for the setpoint node.
    INTEGER :: PltPumpOutletNodeNum = 0   ! node number for the pump outlet (for flow rate)
  ! Calculated and from elsewhere
    LOGICAL :: Init                 = .true. ! flag for initializationL true means do the initializations
    REAL(r64)    :: FlowDivFract         = 0.0d0 ! Fraction of flow sent down diversion path
    REAL(r64)    :: Stream2SourceTemp    = 0.0d0 ! Temperature [C] of stream 2 being mixed
    REAL(r64)    :: InletTemp            = 0.0d0 ! Temperature [C] of inlet to valve
    REAL(r64)    :: SetpointTemp         = 0.0d0 ! setpoint Temperatures [C] at control node.
    REAL(r64)    :: MixedMassFlowRate    = 0.0d0 ! Flow rate downstream of mixer [kg/s]
    REAL(r64)    :: DivertedFlowRate     = 0.0d0 ! flow rate through tempering valve's diversion path [kg/s]
   !loop topology variables
   INTEGER       :: LoopNum         =0
   INTEGER       :: LoopSideNum     =0
   INTEGER       :: BranchNum       =0
   INTEGER       :: CompNum         =0
END TYPE TemperValveData

TYPE (TemperValveData), ALLOCATABLE, DIMENSION(:):: TemperValve  !dimension to No. of TemperingValve objects
          ! MODULE VARIABLE DECLARATIONS:
INTEGER :: NumTemperingValves
LOGICAL, ALLOCATABLE, DIMENSION(:) :: CheckEquipName

          ! SUBROUTINE SPECIFICATIONS FOR MODULE <module_name>:

PUBLIC  SimPlantValves
PRIVATE GetPlantValvesInput
PRIVATE InitPlantValves
PRIVATE CalcPlantValves
PRIVATE UpdatePlantValves
PRIVATE ReportPlantValves

CONTAINS

SUBROUTINE SimPlantValves(CompTypeNum,CompName,CompNum,RunFlag,InitLoopEquip,  &
                          MyLoad,MaxCap,MinCap,OptCap,FirstHVACIteration)

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         B. Griffith, NREL
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! Simulation manager for Plant valves

          ! METHODOLOGY EMPLOYED:
          ! <description>

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE DataGlobals, ONLY: BeginEnvrnFlag
  USE DataInterfaces, ONLY: ShowFatalError, ShowContinueError, ShowSevereError
  USE InputProcessor, ONLY: FindItemInList

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
  INTEGER, INTENT(IN)          :: CompTypeNum
  CHARACTER(len=*), INTENT(IN) :: CompName
  INTEGER                      :: CompNum
  LOGICAL, INTENT(IN)          :: RunFlag !unused1208
  LOGICAL, INTENT(INOUT)       :: InitLoopEquip
  REAL(r64), INTENT(INOUT)     :: MyLoad !unused1208
  REAL(r64), INTENT(OUT)       :: MinCap
  REAL(r64), INTENT(OUT)       :: MaxCap
  REAL(r64), INTENT(OUT)       :: OptCap
  LOGICAL, INTENT(IN)          :: FirstHVACIteration ! TRUE if First iteration of simulation

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  LOGICAL,SAVE      :: GetInputFlag = .true.  ! First time, input is "gotten"
  INTEGER :: EqNum

  IF (GetInputFlag) THEN
    CALL GetPlantValvesInput
    GetInputFlag=.false.
  ENDIF

  ! Find the correct Equipment
  IF (CompNum == 0) THEN
    EqNum = FindItemInList(CompName, TemperValve%Name, NumTemperingValves)
    IF (EqNum == 0) THEN
      CALL ShowFatalError('SimPlantValves: Unit not found='//TRIM(CompName))
    ENDIF
    CompNum=EqNum
  ELSE
    EqNum=CompNum
    IF (EqNum > NumTemperingValves .or. EqNum < 1) THEN
      CALL ShowFatalError('SimPlantValves:  Invalid CompNum passed='//  &
                          TRIM(TrimSigDigits(EqNum))// &
                          ', Number of Units='//TRIM(TrimSigDigits(NumTemperingValves))//  &
                          ', Entered Unit name='//TRIM(CompName))
    ENDIF
    IF (CheckEquipName(EqNum)) THEN
      IF (CompName /= TemperValve(EqNum)%Name) THEN
        CALL ShowFatalError('SimPlantValves: Invalid CompNum passed='//  &
                            TRIM(TrimSigDigits(EqNum))// &
                            ', Unit name='//TRIM(CompName)//', stored Unit Name for that index='//  &
                            TRIM(TemperValve(EqNum)%Name))
      ENDIF
      CheckEquipName(EqNum)=.false.
    ENDIF
  ENDIF

  IF (InitLoopEquip) THEN
    MinCap = 0.0d0
    MaxCap = 0.0d0
    OptCap = 0.0d0
    RETURN
  ENDIF

  CALL InitPlantValves(CompTypeNum,CompNum)

  CALL CalcPlantValves(CompTypeNum,CompNum)

  CALL UpdatePlantValves(CompTypeNum,CompNum)

  CALL ReportPlantValves !(Args)

  RETURN

END SUBROUTINE SimPlantValves

SUBROUTINE GetPlantValvesInput

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         Brent Griffith
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! get input from user

          ! METHODOLOGY EMPLOYED:
          ! usual method using InputProcessor

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE DataInterfaces, ONLY :  ShowSevereError, ShowWarningError, ShowFatalError, SetupOutputVariable
  USE InputProcessor, ONLY: GetNumObjectsFound, GetObjectItem ! might also use FindItemInList
  USE DataIPShortCuts  ! Data for field names, blank numerics
  USE BranchNodeConnections, ONLY: TestCompSet
  USE NodeInputManager,   ONLY: GetOnlySingleNode

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
          ! na

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  INTEGER                        :: Item    ! Item to be "gotten"
  CHARACTER(len=MaxNameLength), &
                    DIMENSION(6) :: Alphas  ! Alpha items for object
  REAL(r64), DIMENSION(1)             :: Numbers ! Numeric items for object
  INTEGER                        :: NumAlphas  ! Number of Alphas for each GetObjectItem call
  INTEGER                        :: NumNumbers ! Number of Numbers for each GetObjectItem call
  INTEGER                        :: IOStatus   ! Used in GetObjectItem
  LOGICAL                        :: ErrorsFound=.false.  ! Set to true if errors in input, fatal at end of routine
  CHARACTER(len=MaxNameLength)   :: CurrentModuleObject  ! for ease in renaming.

 CurrentModuleObject = 'TemperingValve'
 NumTemperingValves = GetNumObjectsFound(CurrentModuleObject)

 ALLOCATE(TemperValve(NumTemperingValves))
 ALLOCATE(CheckEquipName(NumTemperingValves))
 CheckEquipName=.true.

  DO Item=1,NumTemperingValves

    CALL GetObjectItem(CurrentModuleObject,Item,Alphas,NumAlphas,Numbers,NumNumbers,IOStatus)
  !  <process, noting errors>
     TemperValve(Item)%Name = Alphas(1)
  ! Get Plant Inlet Node
     TemperValve(Item)%PltInletNodeNum     = &
               GetOnlySingleNode(Alphas(2),ErrorsFound,TRIM(CurrentModuleObject),Alphas(1), &
               NodeType_Water,NodeConnectionType_Inlet, 1, ObjectIsNotParent)
  ! Get Plant Outlet Node
     TemperValve(Item)%PltOutletNodeNum = &
               GetOnlySingleNode(Alphas(3),ErrorsFound,TRIM(CurrentModuleObject),Alphas(1), &
               NodeType_Water,NodeConnectionType_Outlet, 1, ObjectIsNotParent)

  ! Get Stream 2 Source Node
     TemperValve(Item)%PltStream2NodeNum =  &
               GetOnlySingleNode(Alphas(4),ErrorsFound,TRIM(CurrentModuleObject),Alphas(1), &
               NodeType_Water,NodeConnectionType_Sensor, 1, ObjectIsNotParent)
  ! Get Mixed water Setpoint
     TemperValve(Item)%PltSetPointNodeNum =  &
               GetOnlySingleNode(Alphas(5),ErrorsFound,TRIM(CurrentModuleObject),Alphas(1), &
               NodeType_Water,NodeConnectionType_Setpoint, 1, ObjectIsNotParent)

  ! Get Pump outlet
     TemperValve(Item)%PltPumpOutletNodeNum =  &
               GetOnlySingleNode(Alphas(6),ErrorsFound,TRIM(CurrentModuleObject),Alphas(1), &
               NodeType_Water,NodeConnectionType_Sensor, 1, ObjectIsNotParent)


    ! Note most checks on user input are made in second pass thru init routine

     CALL TestCompSet(TRIM(CurrentModuleObject), Alphas(1), Alphas(2), Alphas(3), 'Supply Side Water Nodes')

  ENDDO

  DO Item=1,NumTemperingValves

      CALL SetupOutputVariable('Tempering Valve Flow Fraction []', &
          TemperValve(Item)%FlowDivFract,'System','Average',TemperValve(Item)%Name)
  ENDDO

  IF (ErrorsFound) THEN
    CALL ShowFatalError('GetPlantValvesInput: '//TRIM(CurrentModuleObject)//' Errors found in input')
  ENDIF

  RETURN

END SUBROUTINE GetPlantValvesInput

SUBROUTINE InitPlantValves(CompTypeNum,CompNum)

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         B. Griffith, NREL
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! intialize data for valve modeling

          ! METHODOLOGY EMPLOYED:
          !

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE DataGlobals,       ONLY: BeginEnvrnFlag
  USE DataInterfaces,    ONLY: ShowSevereError, ShowWarningError, ShowContinueError, ShowContinueErrorTimeStamp
  USE DataLoopNode,      ONLY: Node
  USE DataPlant,         ONLY: TypeOf_ValveTempering, PlantLoop, ScanPlantLoopsForObject, &
                               GenEquipTypes_Pump, TypeOf_ValveTempering
  USE DataBranchAirLoopPlant, ONLY : ControlType_Active
  USE InputProcessor,    ONLY: SameString
  USE DataHVACGlobals,   ONLY: NumPlantLoops
  USE PlantUtilities,    ONLY: InitComponentNodes

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
  INTEGER, INTENT(IN)          :: CompTypeNum
  INTEGER , INTENT(IN)         :: CompNum
          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  INTEGER :: InletNode  ! local working variable for inlet node number
  INTEGER :: OutletNode ! local working variable for outlet node number
  INTEGER :: Strm2Node  ! local working variable for stream 2 outlet node number
  INTEGER :: SetPntNode ! local working variable for setpoint node number
  INTEGER :: PumpOutNode ! local working variable for pump outlet node number

  INTEGER :: i  ! plant loop do loop counter
  INTEGER :: j  ! plant half loop do loop counter
  INTEGER :: k  ! plant branches do loop counter
  Integer :: kk ! plant branches do loop counter, nested
  INTEGER :: l  ! plant components do loop counter
!  INTEgER :: ll ! plant components do loop counter, nested
  INTEGER :: m  ! plant splitter do loop counter
  INTEGER :: n  ! plant mixer do loop counter
  LOGICAL :: InNodeOnSplitter  ! input data check
  LOGICAL :: PumpOutNodeOkay ! input data check
  LOGICAL :: ErrorsFound  ! input data check
  LOGICAL :: TwoBranchesBetwn ! input data check
  LOGICAL :: SetpointNodeOkay ! input data check
  LOGICAL :: Stream2NodeOkay  ! input data check
  LOGICAL :: IsBranchActive   ! input data check

  INTEGER :: numLoopSides ! set to SIZE(PlantLoop(i)%LoopSide)

  LOGICAL, SAVE :: MyOneTimeFlag = .true. ! first pass log
  LOGICAL, ALLOCATABLE, DIMENSION(:), SAVE :: MyTwoTimeFlag ! second pass do input check
  LOGICAL :: errFlag


  SELECT CASE (CompTypeNum)

  CASE (TypeOf_ValveTempering)

  IF (MyOneTimeFlag) THEN
     MyOneTimeFlag = .false.
     ALLOCATE(MyTwoTimeFlag(NumTemperingValves))
     MyTwoTimeFlag=.true.
  ELSE
    ! delay checks one pass so more of plant data structure gets filled in
    IF (MyTwoTimeFlag(CompNum)) THEN
    ! do some checks on input data
     ! Search thru PlantLoop Data Structure to check some things.
       ! Locate the component on the plant loops for later usage
       errFlag=.false.
       CALL ScanPlantLoopsForObject(TemperValve(CompNum)%Name, &
                                    TypeOf_ValveTempering, &
                                    TemperValve(CompNum)%LoopNum, &
                                    TemperValve(CompNum)%LoopSideNum, &
                                    TemperValve(CompNum)%BranchNum, &
                                    TemperValve(CompNum)%CompNum,  &
                                    errFlag=errFlag)

       IF (errFlag) THEN
         CALL ShowFatalError('InitPlantValves: Program terminated due to previous condition(s).')
       ENDIF
     ! init logical flags
       ErrorsFound      = .FALSE.
       InNodeOnSplitter = .FALSE.
       PumpOutNodeOkay  = .FALSE.
       TwoBranchesBetwn = .FALSE.
       SetpointNodeOkay = .FALSE.
       Stream2NodeOkay  = .FALSE.
       IsBranchActive   = .FALSE.

     ! . A) find indexes of PlantLoop, Half loop, and Branch by searching CompData
       IF (ALLOCATED(PlantLoop)) THEN
         DO i = 1, NumPlantLoops
           IF (.NOT.ALLOCATED(PlantLoop(i)%LoopSide)) CYCLE
           numLoopSides = SIZE(PlantLoop(i)%LoopSide)
           DO j = 1, numLoopSides
             IF (.NOT.ALLOCATED(PlantLoop(i)%LoopSide(j)%Branch)) CYCLE
             DO k = 1, PlantLoop(i)%LoopSide(j)%TotalBranches
               IF (.NOT.ALLOCATED(PlantLoop(i)%LoopSide(j)%Branch(k)%Comp)) CYCLE
               DO l = 1, PlantLoop(i)%LoopSide(j)%Branch(k)%TotalComponents

                 IF  ( ( PlantLoop(i)%LoopSide(j)%Branch(k)%Comp(l)%TypeOf_Num == CompTypeNum) .AND. &
                     (PlantLoop(i)%LoopSide(j)%Branch(k)%Comp(l)%CompNum == CompNum)) THEN ! we found it.

                   IF (.not.SameString(PlantLoop(i)%LoopSide(j)%Branch(k)%Comp(l)%Name, TemperValve(CompNum)%Name)) THEN
                     ! why not, maybe plant loop structures not completely filled with available data?
                  !write(*,*) 'Temper Valve names', PlantLoop(i)%LoopSide(j)%Branch(k)%Comp(l)%Name, TemperValve(CompNum)%Name
                   ENDIF

                   ! is branch control type 'Active'
                 IF (PlantLoop(i)%LoopSide(j)%Branch(k)%ControlType == ControlType_Active) IsBranchActive = .true.

                    ! is Valve inlet node an outlet node of a splitter
                   IF (ALLOCATED(PlantLoop(i)%LoopSide(j)%Splitter)) THEN
                     DO m = 1, PlantLoop(i)%LoopSide(j)%NumSplitters
                       IF (ALLOCATED(PlantLoop(i)%LoopSide(j)%Splitter(m)%NodeNumOut)) THEN
                         IF (ANY(PlantLoop(i)%LoopSide(j)%Splitter(m)%NodeNumOut &
                               == TemperValve(CompNum)%PltInletNodeNum)) THEN
                             InNodeOnSplitter = .true.
                         ENDIF
                       ENDIF ! allocated

                       ! are there only 2 branches between splitter and mixer?
                       IF (PlantLoop(i)%LoopSide(j)%Splitter(m)%TotalOutletNodes == 2) THEN
                         TwoBranchesBetwn = .true.
                       ENDIF
                     ENDDO !loop over splitters
                   ENDIF ! allocated %splitter

                  ! is stream 2 node an inlet to the mixer ?
                   IF (ALLOCATED(PlantLoop(i)%LoopSide(j)%Mixer)) THEN
                      DO n = 1, PlantLoop(i)%LoopSide(j)%NumMixers
                        IF (.NOT. ALLOCATED(PlantLoop(i)%LoopSide(j)%Mixer(n)%NodeNumIn)) CYCLE
                        IF (ANY(PlantLoop(i)%LoopSide(j)%Mixer(n)%NodeNumIn  &
                               == TemperValve(CompNum)%PltStream2NodeNum)) THEN

                           ! Check other branches component's node, current branch is k
                             DO kk = 1, PlantLoop(i)%LoopSide(j)%TotalBranches
                               IF (k == kk) CYCLE  !already looped into this one
                               IF (.NOT. ALLOCATED(PlantLoop(i)%LoopSide(j)%Branch(KK)%Comp)) CYCLE
                                 IF (ANY(PlantLoop(i)%LoopSide(j)%Branch(kk)%Comp%NodeNumOut &
                                     == TemperValve(CompNum)%PltStream2NodeNum)) THEN !it is on other branch

                                     Stream2NodeOkay = .TRUE.

                                 ENDIF
                             ENDDO ! kk branch nested loop
                        ENDIF ! stream 2 node is inlet to mixer
                      ENDDO  !mixer loop
                   ENDIF ! mixer allocated

                   ! is pump node really the outlet of a branch with a pump?
                   DO kk=1, PlantLoop(i)%LoopSide(j)%TotalBranches
                      IF (PlantLoop(i)%LoopSide(j)%Branch(kk)%NodeNumOut == TemperValve(CompNum)%PltPumpOutletNodeNum) THEN
                         IF (ANY(PlantLoop(i)%LoopSide(j)%Branch(kk)%Comp%GeneralEquipType==GenEquipTypes_Pump)) THEN
                         !IF (PlantLoop(i)%LoopSide(j)%Branch(kk)%PumpPresent) THEN
                           PumpOutNodeOkay = .true.
                         ENDIF
                      ENDIF
                    ENDDO

                 ! does sensor node agree with plant loop setpoint?
                 IF (PlantLoop(i)%TempSetPointNodeNum == TemperValve(CompNum)%PltSetPointNodeNum) THEN
                   SetpointNodeOkay = .TRUE.
                 ENDIF

               ENDIF !found item

               ENDDO ! comps  l
             ENDDO ! Branches k
           ENDDO ! Loop Sides j
         ENDDO  ! Plant loops i
       ENDIF ! plant loop allocated

      IF (.NOT.IsBranchActive) THEN
        CALL ShowSevereError('TemperingValve object needs to be on an ACTIVE branch')
        ErrorsFound = .true.
      ENDIF

      IF (.NOT.InNodeOnSplitter) THEN
        CALL ShowSevereError('TemperingValve object needs to be between a Splitter and Mixer')
        ErrorsFound = .true.
      ENDIF

      IF (.NOT.PumpOutNodeOkay) THEN
        CALL ShowSevereError('TemperingValve object needs to reference a node that is the outlet of a pump on its loop')
        ErrorsFound = .true.
      ENDIF

      IF (.NOT.TwoBranchesBetwn) THEN
        CALL ShowSevereError('TemperingValve object needs exactly two branches between a Splitter and Mixer')
        ErrorsFound = .true.
      ENDIF

      IF (.NOT.SetpointNodeOkay) THEN
        CALL ShowSevereError('TemperingValve object setpoint node not valid.  '//  &
                            'Check Setpoint manager for Plant Loop Temp Setpoint')
        ErrorsFound = .true.
      ENDIF

      IF (.NOT.Stream2NodeOkay) THEN
        CALL ShowSevereError('TemperingValve object stream 2 source node not valid.')
        CALL ShowContinueError('Check that node is a component outlet, enters a mixer, and on the other branch')
        ErrorsFound = .true.
      ENDIF
      IF (ErrorsFound) THEN
        CALL ShowFatalError('Errors found in input, TemperingValve object '// trim(TemperValve(CompNum)%Name))
      ENDIF
      MyTwoTimeFlag(CompNum) = .false.
    ENDIF ! my two time flag for input checking

  ENDIF ! my one time flag for input checking

  InletNode  = TemperValve(CompNum)%PltInletNodeNum
  OutletNode = TemperValve(CompNum)%PltOutletNodeNum
  Strm2Node  = TemperValve(CompNum)%PltStream2NodeNum
  SetPntNode = TemperValve(CompNum)%PltSetPointNodeNum
  PumpOutNode= TemperValve(CompNum)%PltPumpOutletNodeNum

  IF ((BeginEnvrnFlag) .AND. (TemperValve(CompNum)%init)) THEN

    IF ((InletNode > 0) .AND. (OutletNode > 0)) THEN
    !   Node(InletNode)%Temp = 0.0
       Call InitComponentNodes(0.d0, Node(PumpOutNode)%MassFlowRateMax, &
                               TemperValve(CompNum)%PltInletNodeNum, &
                               TemperValve(CompNum)%PltOutletNodeNum, &
                               TemperValve(CompNum)%LoopNum, &
                               TemperValve(CompNum)%LoopSideNum, &
                               TemperValve(CompNum)%BranchNum, &
                               TemperValve(CompNum)%CompNum )

    ENDIF
    TemperValve(CompNum)%Init = .False.
  ENDIF

  IF (.NOT. BeginEnvrnFlag) TemperValve(CompNum)%Init = .TRUE.

  IF (InletNode > 0) THEN
    TemperValve(CompNum)%InletTemp = Node(InletNode)%Temp
  ENDIF
  IF (Strm2Node > 0) THEN
    TemperValve(CompNum)%Stream2SourceTemp = Node(Strm2Node)%Temp
  ENDIF
  IF (SetPntNode > 0) THEN
    TemperValve(CompNum)%SetpointTemp = Node(SetPntNode)%TempSetPoint
  ENDIF

  IF (PumpOutNode > 0) THEN
    TemperValve(CompNum)%MixedMassFlowRate = Node(PumpOutNode)%MassFlowRate
  ENDIF

  CASE DEFAULT
    ! should not come here, would have been caught already
  END SELECT

  RETURN

END SUBROUTINE InitPlantValves

SUBROUTINE CalcPlantValves(CompTypeNum,CompNum)

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         B. Griffith, NREL
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          !  This routine does the calculations for Valves.
          !  Currently only one type of valve, for Tempering.


          ! METHODOLOGY EMPLOYED:
          !   Tempering valve calculations involve computing a flow fraction
          !     that should be diverted.  See update routine for setting flow rates.

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE DataPlant, ONLY : PlantLoop, TypeOf_ValveTempering
  USE DataGlobals, ONLY : KickOffSimulation

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
  INTEGER,  INTENT(IN)    :: CompTypeNum
  INTEGER , INTENT(IN)    :: CompNum

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  REAL(r64) :: Tin  ! local working variable for Inlet Temperature (C)
  REAL(r64) :: Tset ! local working variable for Setpoint Temperature (C)
  REAL(r64) :: Ts2  ! local Working Variable for Stream 2 outlet Temperature (C)
  INTEGER :: LoopNum
  INTEGER :: LoopSideNum

  LoopNum = TemperValve(CompNum)%LoopNum
  LoopSideNum = TemperValve(CompNum)%LoopSideNum

  IF (KickOffSimulation) RETURN

  SELECT CASE (CompTypeNum)

  CASE (TypeOf_ValveTempering)

    IF (PlantLoop(LoopNum)%Loopside(LoopSideNum)%FlowLock == 0) THEN
      Tin = TemperValve(CompNum)%InletTemp
      Tset = TemperValve(CompNum)%SetpointTemp
      Ts2 = TemperValve(CompNum)%Stream2SourceTemp

      IF (Ts2 <= Tset) THEN
        TemperValve(CompNum)%FlowDivFract = 0.0d0
      ELSE  ! Divert some or all flow
        IF (Tin < Ts2) THEN
          TemperValve(CompNum)%FlowDivFract = (Ts2 - Tset) / (Ts2 - Tin)
        ELSE
          TemperValve(CompNum)%FlowDivFract = 1.0d0
        END IF
      END IF
    ELSEIF (PlantLoop(LoopNum)%Loopside(LoopSideNum)%FlowLock == 1) THEN ! don't recalc diversion, just reuse current flows
      IF (TemperValve(CompNum)%MixedMassFlowRate > 0.0d0) Then
        TemperValve(CompNum)%FlowDivFract = Node(TemperValve(CompNum)%PltOutletNodeNum)%MassFlowRate &
                                           / TemperValve(CompNum)%MixedMassFlowRate
      ELSE
        TemperValve(CompNum)%FlowDivFract = 0.0d0
      ENDIF

    END IF

    IF (TemperValve(CompNum)%FlowDivFract < 0.0d0) TemperValve(CompNum)%FlowDivFract = 0.0d0
    IF (TemperValve(CompNum)%FlowDivFract > 1.0d0) TemperValve(CompNum)%FlowDivFract = 1.0d0

  CASE DEFAULT
    ! should not come here. would have been caught in init routine

  END SELECT

  RETURN

END SUBROUTINE CalcPlantValves

SUBROUTINE UpdatePlantValves(CompTypeNum,CompNum)

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         B. Griffith, NREL
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! Propagate calculations to rest of program

          ! METHODOLOGY EMPLOYED:
          ! set values at nodes

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
  USE PlantUtilities, ONLY: SetComponentFlowRate, SafeCopyPlantNode
  USE DataPlant,      ONLY: TypeOf_ValveTempering

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
  INTEGER , INTENT(IN)    :: CompTypeNum
  INTEGER , INTENT(IN)    :: CompNum

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
  REAL(r64)   :: mdot !local fluid mass flow rate

  SELECT CASE (CompTypeNum)

  CASE (TypeOf_ValveTempering)

    CALL SafeCopyPlantNode(TemperValve(CompNum)%PltInletNodeNum, TemperValve(CompNum)%PltOutletNodeNum)

    ! set mass flows in diverter path
    mdot =  TemperValve(CompNum)%MixedMassFlowRate   &
                                             * TemperValve(CompNum)%FlowDivFract

    IF (TemperValve(CompNum)%LoopNum > 0) THEN
      CALL SetComponentFlowRate( mdot, &
                                 TemperValve(CompNum)%PltInletNodeNum,  &
                                 TemperValve(CompNum)%PltOutletNodeNum, &
                                 TemperValve(CompNum)%LoopNum,          &
                                 TemperValve(CompNum)%LoopSideNum,      &
                                 TemperValve(CompNum)%BranchNum,        &
                                 TemperValve(CompNum)%CompNum  )

      TemperValve(CompNum)%DivertedFlowRate = mdot
    ELSE
      TemperValve(CompNum)%DivertedFlowRate = 0.d0
    ENDIF
  CASE DEFAULT

    ! should not come here
  END SELECT

  RETURN

END SUBROUTINE UpdatePlantValves

SUBROUTINE ReportPlantValves

          ! SUBROUTINE INFORMATION:
          !       AUTHOR         B. Griffith, NREL
          !       DATE WRITTEN   Jan. 2006
          !       MODIFIED       na
          !       RE-ENGINEERED  na

          ! PURPOSE OF THIS SUBROUTINE:
          ! <description>

          ! METHODOLOGY EMPLOYED:
          ! <description>

          ! REFERENCES:
          ! na

          ! USE STATEMENTS:
          ! na

  IMPLICIT NONE ! Enforce explicit typing of all variables in this routine

          ! SUBROUTINE ARGUMENT DEFINITIONS:
          ! na

          ! SUBROUTINE PARAMETER DEFINITIONS:
          ! na

          ! INTERFACE BLOCK SPECIFICATIONS:
          ! na

          ! DERIVED TYPE DEFINITIONS:
          ! na

          ! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
          ! na

  !<this routine is typically needed only for those cases where you must transform the internal data to a reportable form>

! Nothing needs to be done (yet)

  RETURN

END SUBROUTINE ReportPlantValves

!     NOTICE
!
!     Copyright © 1996-2013 The Board of Trustees of the University of Illinois
!     and The Regents of the University of California through Ernest Orlando Lawrence
!     Berkeley National Laboratory.  All rights reserved.
!
!     Portions of the EnergyPlus software package have been developed and copyrighted
!     by other individuals, companies and institutions.  These portions have been
!     incorporated into the EnergyPlus software package under license.   For a complete
!     list of contributors, see "Notice" located in EnergyPlus.f90.
!
!     NOTICE: The U.S. Government is granted for itself and others acting on its
!     behalf a paid-up, nonexclusive, irrevocable, worldwide license in this data to
!     reproduce, prepare derivative works, and perform publicly and display publicly.
!     Beginning five (5) years after permission to assert copyright is granted,
!     subject to two possible five year renewals, the U.S. Government is granted for
!     itself and others acting on its behalf a paid-up, non-exclusive, irrevocable
!     worldwide license in this data to reproduce, prepare derivative works,
!     distribute copies to the public, perform publicly and display publicly, and to
!     permit others to do so.
!
!     TRADEMARKS: EnergyPlus is a trademark of the US Department of Energy.
!

END MODULE PlantValves

AirflowNetworkBalanceManager.f90 AirflowNetworkSolver.f90 BaseboardRadiator.f90 BaseboardRadiatorElectric.f90 BaseboardRadiatorSteam.f90 BaseboardRadiatorWater.f90 BranchInputManager.f90 BranchNodeConnections.f90 ConductionTransferFunctionCalc.f90 CoolTower.f90 CostEstimateManager.f90 CurveManager.f90 CVFOnlyRoutines.f90 DataAirflowNetwork.f90 DataAirLoop.f90 DataAirSystems.f90 DataBranchAirLoopPlant.f90 DataBranchNodeConnections.f90 DataBSDFWindow.f90 DataComplexFenestration.f90 DataContaminantBalance.f90 DataConvergParams.f90 DataConversions.f90 DataCostEstimate.f90 DataDaylighting.f90 DataDaylightingDevices.f90 Datadefineequip.f90 DataDElight.f90 DataEnvironment.f90 DataEquivalentLayerWindow.f90 DataErrorTracking.f90 DataGenerators.f90 DataGlobalConstants.f90 DataGlobals.f90 DataHeatBalance.f90 DataHeatBalFanSys.f90 DataHeatBalSurface.f90 DataHVACControllers.f90 DataHVACGlobals.f90 DataInterfaces.f90 DataIPShortCuts.f90 DataLoopNode.f90 DataMoistureBalance.f90 DataMoistureBalanceEMPD.f90 DataOutputs.f90 DataPhotovoltaics.f90 DataPlant.f90 DataPlantPipingSystems.f90 DataPrecisionGlobals.f90 DataReportingFlags.f90 DataRoomAir.f90 DataRootFinder.f90 DataRuntimeLanguage.f90 DataShadowingCombinations.f90 DataSizing.f90 DataStringGlobals.f90 DataSurfaceColors.f90 DataSurfaceLists.f90 DataSurfaces.f90 DataSystemVariables.f90 DataTimings.f90 DataUCSDSharedData.f90 DataVectorTypes.f90 DataViewFactorInformation.f90 DataWater.f90 DataZoneControls.f90 DataZoneEnergyDemands.f90 DataZoneEquipment.f90 DaylightingDevices.f90 DaylightingManager.f90 DElightManagerF.f90 DElightManagerF_NO.f90 DemandManager.f90 DesiccantDehumidifiers.f90 DirectAir.f90 DisplayRoutines.f90 DXCoil.f90 EarthTube.f90 EconomicLifeCycleCost.f90 EconomicTariff.f90 EcoRoof.f90 ElectricPowerGenerators.f90 ElectricPowerManager.f90 EMSManager.f90 EnergyPlus.f90 ExteriorEnergyUseManager.f90 ExternalInterface_NO.f90 FanCoilUnits.f90 FaultsManager.f90 FluidProperties.f90 General.f90 GeneralRoutines.f90 GlobalNames.f90 HeatBalanceAirManager.f90 HeatBalanceConvectionCoeffs.f90 HeatBalanceHAMTManager.f90 HeatBalanceInternalHeatGains.f90 HeatBalanceIntRadExchange.f90 HeatBalanceManager.f90 HeatBalanceMovableInsulation.f90 HeatBalanceSurfaceManager.f90 HeatBalFiniteDifferenceManager.f90 HeatRecovery.f90 Humidifiers.f90 HVACControllers.f90 HVACCooledBeam.f90 HVACDualDuctSystem.f90 HVACDuct.f90 HVACDXSystem.f90 HVACEvapComponent.f90 HVACFanComponent.f90 HVACFurnace.f90 HVACHeatingCoils.f90 HVACHXAssistedCoolingCoil.f90 HVACInterfaceManager.f90 HVACManager.f90 HVACMixerComponent.f90 HVACMultiSpeedHeatPump.f90 HVACSingleDuctInduc.f90 HVACSingleDuctSystem.f90 HVACSplitterComponent.f90 HVACStandAloneERV.f90 HVACSteamCoilComponent.f90 HVACTranspiredCollector.f90 HVACUnitaryBypassVAV.f90 HVACUnitarySystem.f90 HVACVariableRefrigerantFlow.f90 HVACWaterCoilComponent.f90 HVACWatertoAir.f90 HVACWatertoAirMultiSpeedHP.f90 InputProcessor.f90 MatrixDataManager.f90 MixedAir.f90 MoistureBalanceEMPDManager.f90 NodeInputManager.f90 NonZoneEquipmentManager.f90 OutAirNodeManager.f90 OutdoorAirUnit.f90 OutputProcessor.f90 OutputReportPredefined.f90 OutputReports.f90 OutputReportTabular.f90 PackagedTerminalHeatPump.f90 PackagedThermalStorageCoil.f90 Photovoltaics.f90 PhotovoltaicThermalCollectors.f90 PlantAbsorptionChillers.f90 PlantBoilers.f90 PlantBoilersSteam.f90 PlantCentralGSHP.f90 PlantChillers.f90 PlantCondLoopOperation.f90 PlantCondLoopTowers.f90 PlantEIRChillers.f90 PlantEvapFluidCoolers.f90 PlantExhaustAbsorptionChiller.f90 PlantFluidCoolers.f90 PlantGasAbsorptionChiller.f90 PlantGroundHeatExchangers.f90 PlantHeatExchanger.f90 PlantIceThermalStorage.f90 PlantLoadProfile.f90 PlantLoopEquipment.f90 PlantLoopSolver.f90 PlantManager.f90 PlantOutsideEnergySources.f90 PlantPipeHeatTransfer.f90 PlantPipes.f90 PlantPipingSystemManager.f90 PlantPondGroundHeatExchanger.f90 PlantPressureSystem.f90 PlantPumps.f90 PlantSolarCollectors.f90 PlantSurfaceGroundHeatExchanger.f90 PlantUtilities.f90 PlantValves.f90 PlantWaterSources.f90 PlantWaterThermalTank.f90 PlantWatertoWaterGSHP.f90 PlantWaterUse.f90 PollutionAnalysisModule.f90 PoweredInductionUnits.f90 PsychRoutines.f90 Purchasedairmanager.f90 RadiantSystemHighTemp.f90 RadiantSystemLowTemp.f90 RefrigeratedCase.f90 ReportSizingManager.f90 ReturnAirPath.f90 RoomAirManager.f90 RoomAirModelCrossVent.f90 RoomAirModelDisplacementVent.f90 RoomAirModelMundt.f90 RoomAirModelUFAD.f90 RoomAirModelUserTempPattern.f90 RootFinder.f90 RuntimeLanguageProcessor.f90 ScheduleManager.f90 SetPointManager.f90 SimAirServingZones.f90 SimulationManager.f90 SizingManager.f90 SolarReflectionManager.f90 SolarShading.f90 SortAndStringUtilities.f90 sqlite3.c SQLiteCRoutines.c SQLiteFortranRoutines.f90 SQLiteFortranRoutines_NO.f90 StandardRatings.f90 SurfaceGeometry.f90 SystemAvailabilityManager.f90 SystemReports.f90 TarcogComplexFenestration.f90 ThermalChimney.f90 ThermalComfort.f90 UnitHeater.f90 UnitVentilator.f90 UserDefinedComponents.f90 UtilityRoutines.f90 VectorUtilities.f90 VentilatedSlab.f90 WaterManager.f90 WeatherManager.f90 WindowAC.f90 WindowComplexManager.f90 WindowEquivalentLayer.f90 WindowManager.f90 WindTurbine.f90 Zoneairloopequipmentmanager.f90 ZoneContaminantPredictorCorrector.f90 ZoneDehumidifier.f90 Zoneequipmentmanager.f90 ZonePlenumComponent.f90 ZoneTempPredictorCorrector.f90