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) | :: | GeneratorNum | |||
logical, | intent(in) | :: | FirstHVACIteration |
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 InitMicroCHPNoNormalizeGenerators(GeneratorNum, FirstHVACIteration)
! SUBROUTINE INFORMATION:
! AUTHOR BGriffith
! DATE WRITTEN March 2007
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! inits
! METHODOLOGY EMPLOYED:
!
! REFERENCES:
! na
! USE STATEMENTS:
Use DataHVACGlobals, ONLY: SysTimeElapsed, TimeStepSys
USE DataGlobals , ONLY: TimeStep, TimeStepZone, SecInHour, BeginEnvrnFlag, HourOfDay, &
SysSizingCalc, HoursInDay
USE DataPlant, ONLY: ScanPlantLoopsForObject, TypeOf_Generator_MicroCHP, PlantLoop, &
PlantSizeNotComplete, SupplySide, LoopFlowStatus_TakesWhatGets, &
PlantSizesOkayToFinalize, DemandSide
USE DataSizing, ONLY: PlantSizData
USE PlantUtilities, ONLY: SetComponentFlowRate, InitComponentNodes, RegisterPlantCompDesignFlow
USE CurveManager, ONLY: GetCurveCheck, CurveValue
USE FluidProperties, ONLY: GetDensityGlycol
USE GeneratorDynamicsManager
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: GeneratorNum ! Generator number
LOGICAL, INTENT(IN) :: FirstHVACIteration
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: DynaCntrlNum = 0
REAL(r64) :: TimeElapsed ! Fraction of the current hour that has elapsed (h)
LOGICAL,SAVE :: MyOneTimeFlag = .TRUE. ! Initialization flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyEnvrnFlag ! Used for initializations each begin environment flag
LOGICAL, ALLOCATABLE, SAVE, DIMENSION(:) :: MyPlantScanFlag
LOGICAL :: errFlag
REAL(r64) :: mdot ! local temporary for mass flow rate
REAL(r64) :: rho ! local temporary for fluid density
IF (MyOneTimeFlag) THEN
ALLOCATE(MyEnvrnFlag(NumMicroCHPs))
ALLOCATE(MyPlantScanFlag(NumMicroCHPs))
ALLOCATE(MySizeFlag(NumMicroCHPs))
MyEnvrnFlag = .TRUE.
MyPlantScanFlag = .TRUE.
MySizeFlag = .TRUE.
MyOneTimeFlag = .FALSE.
END IF
IF (MyPlantScanFlag(GeneratorNum) .AND. ALLOCATED(PlantLoop)) THEN
errFlag=.false.
CALL ScanPlantLoopsForObject(MicroCHP(GeneratorNum)%Name, &
TypeOf_Generator_MicroCHP, &
MicroCHP(GeneratorNum)%CWLoopNum, &
MicroCHP(GeneratorNum)%CWLoopSideNum, &
MicroCHP(GeneratorNum)%CWBranchNum, &
MicroCHP(GeneratorNum)%CWCompNum, &
errFlag=errFlag)
IF (errFlag) THEN
CALL ShowFatalError('InitMicroCHPNoNormalizeGenerators: Program terminated for previous conditions.')
ENDIF
IF (.NOT. MicroCHP(GeneratorNum)%A42Model%InternalFlowControl) THEN
!IF this is on the supply side and not internal flow control then reset flow priority to lower
IF (MicroCHP(GeneratorNum)%CWLoopSideNum == SupplySide) THEN
PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%LoopSide(MicroCHP(GeneratorNum)%CWLoopSideNum)&
%Branch(MicroCHP(GeneratorNum)%CWBranchNum)%Comp(MicroCHP(GeneratorNum)%CWCompNum)%FlowPriority &
= LoopFlowStatus_TakesWhatGets
ENDIF
ENDIF
MyPlantScanFlag(GeneratorNum) = .FALSE.
ENDIF
IF (.NOT. SysSizingCalc .AND. MySizeFlag(GeneratorNum) .AND. .NOT. MyPlantScanFlag(GeneratorNum) &
.AND. (PlantSizesOkayToFinalize) ) THEN
rho = GetDensityGlycol(PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%FluidName, &
Node(MicroCHP(GeneratorNum)%PlantInletNodeID)%Temp, &
PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%FluidIndex, &
'InitMicroCHPNoNormalizeGenerators')
IF (MicroCHP(GeneratorNum)%A42Model%InternalFlowControl) THEN ! got a curve
MicroCHP(GeneratorNum)%PlantMassFlowRateMax = 2.0d0 * CurveValue(MicroCHP(GeneratorNum)%A42Model%WaterFlowCurveID, &
MicroCHP(GeneratorNum)%A42Model%MaxElecPower , &
Node(MicroCHP(GeneratorNum)%PlantInletNodeID)%Temp )
ELSEIF (MicroCHP(GeneratorNum)%CWLoopSideNum == SupplySide) THEN
IF (PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%MaxMassFlowRate > 0.d0) THEN
MicroCHP(GeneratorNum)%PlantMassFlowRateMax = PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%MaxMassFlowRate
ELSEIF(PlantLoop(MicroCHP(GeneratorNum)%CWLoopNum)%PlantSizNum > 0) THEN
MicroCHP(GeneratorNum)%PlantMassFlowRateMax = PlantSizData(MicroCHP(GeneratorNum)%CWLoopNum)%DesVolFlowRate * rho
ELSE
MicroCHP(GeneratorNum)%PlantMassFlowRateMax = 2.d0 !
ENDIF
ELSEIF (MicroCHP(GeneratorNum)%CWLoopSideNum == DemandSide) THEN
MicroCHP(GeneratorNum)%PlantMassFlowRateMax = 2.d0 ! would like to use plant loop max but not ready yet
ENDIF
CALL RegisterPlantCompDesignFlow(MicroCHP(GeneratorNum)%PlantInletNodeID,MicroCHP(GeneratorNum)%PlantMassFlowRateMax / rho )
MicroCHP(GeneratorNum)%A42Model%ElecEff &
= CurveValue(MicroCHP(GeneratorNum)%A42Model%ElecEffCurveID , &
MicroCHP(GeneratorNum)%A42Model%MaxElecPower , &
MicroCHP(GeneratorNum)%PlantMassFlowRateMax ,&
Node(MicroCHP(GeneratorNum)%PlantInletNodeID)%Temp )
MicroCHP(GeneratorNum)%A42Model%ThermEff &
= CurveValue(MicroCHP(GeneratorNum)%A42Model%ThermalEffCurveID, &
MicroCHP(GeneratorNum)%A42Model%MaxElecPower , &
MicroCHP(GeneratorNum)%PlantMassFlowRateMax ,&
Node(MicroCHP(GeneratorNum)%PlantInletNodeID)%Temp )
CALL SetupGeneratorControlStateManager(GeneratorNum)
MySizeFlag(GeneratorNum) = .FALSE.
ENDIF
If (MySizeFlag(GeneratorNum)) RETURN
DynaCntrlNum = MicroCHP(GeneratorNum)%DynamicsControlID
IF (BeginEnvrnFlag .and. MyEnvrnFlag(GeneratorNum) ) THEN
!reset to starting condition for different environment runperiods, design days
MicroCHP(GeneratorNum)%A42Model%TengLast = 20.d0
MicroCHP(GeneratorNum)%A42Model%TempCWOutLast = 20.d0
MicroCHP(GeneratorNum)%A42Model%TimeElapsed = 0.d0
MicroCHP(GeneratorNum)%A42Model%opMode = 0
MicroCHP(GeneratorNum)%A42Model%OffModeTime = 0.d0
MicroCHP(GeneratorNum)%A42Model%StandyByModeTime = 0.d0
MicroCHP(GeneratorNum)%A42Model%WarmUpModeTime = 0.d0
MicroCHP(GeneratorNum)%A42Model%NormalModeTime = 0.d0
MicroCHP(GeneratorNum)%A42Model%CoolDownModeTime = 0.d0
MicroCHP(GeneratorNum)%A42Model%Pnet = 0.d0
MicroCHP(GeneratorNum)%A42Model%ElecEff = 0.d0
MicroCHP(GeneratorNum)%A42Model%Qgross = 0.d0
MicroCHP(GeneratorNum)%A42Model%ThermEff = 0.d0
MicroCHP(GeneratorNum)%A42Model%Qgenss = 0.d0
MicroCHP(GeneratorNum)%A42Model%NdotFuel = 0.d0
MicroCHP(GeneratorNum)%A42Model%MdotFuel = 0.d0
MicroCHP(GeneratorNum)%A42Model%Teng = 20.d0
MicroCHP(GeneratorNum)%A42Model%Tcwin = 20.d0
MicroCHP(GeneratorNum)%A42Model%Tcwout = 20.d0
MicroCHP(GeneratorNum)%A42Model%MdotAir = 0.d0
MicroCHP(GeneratorNum)%A42Model%QdotSkin = 0.d0
MicroCHP(GeneratorNum)%A42Model%QdotConvZone = 0.d0
MicroCHP(GeneratorNum)%A42Model%QdotRadZone = 0.d0
GeneratorDynamics(DynaCntrlNum)%LastOpMode = OpModeOFF
GeneratorDynamics(DynaCntrlNum)%CurrentOpMode = OpModeOFF
GeneratorDynamics(DynaCntrlNum)%FractionalDayofLastShutDown = 0.d0
GeneratorDynamics(DynaCntrlNum)%FractionalDayofLastStartUp = 0.d0
GeneratorDynamics(DynaCntrlNum)%HasBeenOn = .FALSE.
GeneratorDynamics(DynaCntrlNum)%DuringStartUp = .FALSE.
GeneratorDynamics(DynaCntrlNum)%DuringShutDown = .FALSE.
GeneratorDynamics(DynaCntrlNum)%FuelMdotLastTimestep = 0.d0
GeneratorDynamics(DynaCntrlNum)%PelLastTimeStep = 0.d0
GeneratorDynamics(DynaCntrlNum)%NumCycles = 0
FuelSupply(MicroCHP(GeneratorNum)%FuelSupplyID)%QskinLoss = 0.d0
CALL InitComponentNodes( 0.d0, MicroCHP(GeneratorNum)%PlantMassFlowRateMax, &
MicroCHP(GeneratorNum)%PlantInletNodeID, &
MicroCHP(GeneratorNum)%PlantOutletNodeID, &
MicroCHP(GeneratorNum)%CWLoopNum, &
MicroCHP(GeneratorNum)%CWLoopSideNum, &
MicroCHP(GeneratorNum)%CWBranchNum, &
MicroCHP(GeneratorNum)%CWCompNum )
ENDIF
IF (.NOT. BeginEnvrnFlag) THEN
MyEnvrnFlag(GeneratorNum) = .TRUE.
END IF
TimeElapsed = HourOfDay + TimeStep * TimeStepZone + SysTimeElapsed
IF (MicroCHP(GeneratorNum)%A42Model%TimeElapsed /= TimeElapsed) THEN
! The simulation has advanced to the next system timestep. Save conditions from the end of the previous system
! timestep for use as the initial conditions of each iteration that does not advance the system timestep.
MicroCHP(GeneratorNum)%A42Model%TengLast = MicroCHP(GeneratorNum)%A42Model%Teng
MicroCHP(GeneratorNum)%A42Model%TempCWOutLast = MicroCHP(GeneratorNum)%A42Model%Tcwout
MicroCHP(GeneratorNum)%A42Model%TimeElapsed = TimeElapsed
GeneratorDynamics(DynaCntrlNum)%LastOpMode = GeneratorDynamics(DynaCntrlNum)%CurrentOpMode
GeneratorDynamics(DynaCntrlNum)%FuelMdotLastTimestep = MicroCHP(GeneratorNum)%A42Model%MdotFuel
GeneratorDynamics(DynaCntrlNum)%PelLastTimeStep = MicroCHP(GeneratorNum)%A42Model%Pnet
ENDIF
IF ( .NOT. MicroCHP(GeneratorNum)%A42Model%InternalFlowControl ) THEN
mdot = MicroCHP(GeneratorNum)%PlantMassFlowRateMax
CALL SetComponentFlowRate(mdot, &
MicroCHP(GeneratorNum)%PlantInletNodeID, &
MicroCHP(GeneratorNum)%PlantOutletNodeID, &
MicroCHP(GeneratorNum)%CWLoopNum, &
MicroCHP(GeneratorNum)%CWLoopSideNum, &
MicroCHP(GeneratorNum)%CWBranchNum, &
MicroCHP(GeneratorNum)%CWCompNum)
MicroCHP(GeneratorNum)%PlantMassFlowRate = mdot
ENDIF
RETURN
END SUBROUTINE InitMicroCHPNoNormalizeGenerators