Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | LoopNum | |||
integer, | intent(in) | :: | LoopSideNum | |||
integer, | intent(in) | :: | BranchNum |
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.
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.
SUBROUTINE BranchPressureDrop(LoopNum,LoopSideNum,BranchNum)
! SUBROUTINE INFORMATION:
! AUTHOR Edwin Lee
! DATE WRITTEN August 2009
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This will choose an appropriate pressure drop calculation routine based on structure flags
! METHODOLOGY EMPLOYED:
! Standard EnergyPlus Methodology
! REFERENCES:
! na
! USE STATEMENTS:
USE DataLoopNode, ONLY : Node
USE FluidProperties, ONLY : GetDensityGlycol, GetViscosityGlycol
USE DataPlant, ONLY : PlantLoop
USE CurveManager, ONLY : CurveValue, PressureCurveValue
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: LoopNum !Plant Loop Index
INTEGER, INTENT(IN) :: LoopSideNum !LoopSide Index (1=Demand, 2=Supply) on Plant Loop LoopNum
INTEGER, INTENT(IN) :: BranchNum !Branch Index on LoopSide LoopSideNum
! SUBROUTINE PARAMETER DEFINITIONS:
CHARACTER(len=*), PARAMETER :: RoutineName = 'CalcPlantPressureSystem'
CHARACTER(len=*), PARAMETER :: DummyFluid = ' '
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: FluidIndex !Plant loop level Fluid Index
INTEGER :: InletNodeNum !Component inlet node number
INTEGER :: OutletNodeNum !Component outlet node number
INTEGER :: PressureCurveType !Type of curve used to evaluate pressure drop
INTEGER :: PressureCurveIndex !Curve index for PerfCurve structure
REAL(r64) :: NodeMassFlow !Nodal mass flow rate {kg/s}
REAL(r64) :: NodeTemperature !Nodal temperature {C}
REAL(r64) :: NodeDensity !Nodal density {kg/m3}
REAL(r64) :: NodeViscosity !Nodal viscosity, assuming mu here (dynamic viscosity)
REAL(r64) :: BranchDeltaPress !Pressure drop for component, {Pa}
INTEGER, SAVE :: ErrorCounter = 0 !For proper error handling
!Exit early if need be
IF (.NOT. PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%HasPressureComponents) THEN
PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureDrop = 0.0d0
PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureEffectiveK = 0.0d0
RETURN
END IF
!Get data from data structure
FluidIndex = PlantLoop(LoopNum)%FluidIndex
InletNodeNum = PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%NodeNumIn
OutletNodeNum = PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%NodeNumOut
PressureCurveType = PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureCurveType
PressureCurveIndex = PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureCurveIndex
!Get nodal conditions
NodeMassFlow = Node(InletNodeNum)%MassFlowRate
NodeTemperature = Node(InletNodeNum)%Temp
NodeDensity = GetDensityGlycol(DummyFluid, NodeTemperature, FluidIndex, RoutineName)
NodeViscosity = GetViscosityGlycol(DummyFluid, NodeTemperature, FluidIndex, RoutineName)
!Call the appropriate pressure calculation routine
SELECT CASE (PressureCurveType)
CASE (PressureCurve_Pressure)
!DeltaP = [f*(L/D) + K] * (rho * V^2) / 2
BranchDeltaPress = PressureCurveValue(PressureCurveIndex, NodeMassFlow, NodeDensity, NodeViscosity)
CASE (PressureCurve_Generic)
!DeltaP = func(mdot)
!Generic curve, only pass V1=mass flow rate
BranchDeltaPress = CurveValue(PressureCurveIndex, NodeMassFlow)
CASE DEFAULT
!Shouldn't end up here, but just in case
ErrorCounter = ErrorCounter + 1
IF (ErrorCounter == 1) THEN
CALL ShowSevereError('Plant pressure simulation encountered a branch which contains invalid branch pressure curve type.')
CALL ShowContinueError('Occurs for branch: '//PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%Name)
CALL ShowContinueError('This error will be issued only once, although other branches may encounter the same problem')
CALL ShowContinueError('For now, pressure drop on this branch will be set to zero.')
CALL ShowContinueError('Verify all pressure inputs and pressure drop output variables to ensure proper simulation')
END IF
END SELECT
!Log this pressure in the data structure to be handled by the update routine later
PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureDrop = BranchDeltaPress
!Update the effective K-value for this branch
IF (NodeMassFlow .GT. 0.0d0) THEN
PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureEffectiveK = BranchDeltaPress / (NodeMassFlow**2.0d0)
ELSE
PlantLoop(LoopNum)%LoopSide(LoopSideNum)%Branch(BranchNum)%PressureEffectiveK = 0.0d0
END IF
RETURN
END SUBROUTINE BranchPressureDrop