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.
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 InitHeatBalHAMT
! SUBROUTINE INFORMATION:
! AUTHOR Phillip Biddulph
! DATE WRITTEN June 2008
! MODIFIED B. Griffith, Aug 2012 for surface-specific algorithms
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! <description>
! METHODOLOGY EMPLOYED:
! <description>
! REFERENCES:
! na
! USE STATEMENTS:
USE General, ONLY: TrimSigDigits, ScanForReports, RoundSigDigits
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
! na
! SUBROUTINE PARAMETER DEFINITIONS:
REAL(r64), PARAMETER :: adjdist=0.00005d0 ! Allowable distance between two cells, also used as limit on cell length
CHARACTER(len=*), PARAMETER :: RoutineName='InitCombinedHeatAndMoistureFiniteElement: '
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: ii
INTEGER :: cid
INTEGER :: cid1
INTEGER :: cid2
INTEGER :: sid
INTEGER :: conid
INTEGER :: lid
INTEGER :: matid
INTEGER :: did
INTEGER :: adj1
INTEGER :: adj2
INTEGER :: errorCount
INTEGER :: concell
INTEGER :: MaterNum
REAL(r64) :: runor
REAL(r64) :: high1
REAL(r64) :: low2
REAL(r64) :: testlen
REAL(r64) :: waterd ! water density
LOGICAL :: DoReport
deltat=TimeStepZone*3600.0d0
! Check the materials information and work out how many cells are required.
errorCount=0
TotCellsMax=0
DO sid=1,TotSurfaces
IF (Surface(sid)%Class == SurfaceClass_Window) CYCLE
IF (Surface(sid)%HeatTransferAlgorithm /= HeatTransferModel_HAMT) CYCLE
conid=Surface(sid)%Construction
IF (conid == 0) CYCLE
DO lid=1,Construct(conid)%TotLayers
matid=Construct(conid)%LayerPoint(lid)
IF (Material(matid)%ROnly) THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name)// &
' cannot contain R-only value materials.')
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'".')
errorCount=errorCount+1
CYCLE
ENDIF
IF(Material(matid)%nmu<0)THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have required Water Vapor Diffusion Resistance Factor (mu) data.')
errorCount=errorCount+1
ENDIF
IF(Material(matid)%niso<0)THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have required isotherm data.')
errorCount=errorCount+1
ENDIF
IF(Material(matid)%nsuc<0)THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have required liquid transport coefficient (suction) data.')
errorCount=errorCount+1
ENDIF
IF(Material(matid)%nred<0)THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have required liquid transport coefficient (redistribution) data.')
errorCount=errorCount+1
ENDIF
IF(Material(matid)%ntc<0)THEN
IF(Material(matid)%Conductivity>0)THEN
CALL ShowWarningError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have thermal conductivity data. Using fixed value.')
Material(matid)%ntc=2
Material(matid)%tcwater(1)=0.0d0
Material(matid)%tcdata(1)=Material(matid)%Conductivity
Material(matid)%tcwater(2)=Material(matid)%isodata(Material(matid)%niso)
Material(matid)%tcdata(2)=Material(matid)%Conductivity
ELSE
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' does not have required thermal conductivity data.')
errorCount=errorCount+1
ENDIF
ENDIF
! convert material water content to RH
waterd=Material(matid)%iwater*Material(matid)%density
CALL interp(Material(matid)%niso,Material(matid)%isodata,Material(matid)%isorh,&
waterd,Material(matid)%irh)
Material(matid)%divs=INT(Material(matid)%Thickness/Material(matid)%divsize)+Material(matid)%divmin
IF(Material(matid)%divs>Material(matid)%divmax) THEN
Material(matid)%divs=Material(matid)%divmax
ENDIF
! Check length of cell - reduce number of divisions if neccessary
DO
testlen=Material(matid)%Thickness* &
((SIN(PI*(-1.0d0/REAL(Material(matid)%divs,r64))-PI/2.0d0)/2.0d0)-(SIN(-PI/2.0d0)/2.0d0))
IF(testlen>adjdist)EXIT
Material(matid)%divs= Material(matid)%divs-1
IF(Material(matid)%divs<1)THEN
CALL ShowSevereError(RoutineName//'Construction='//trim(Construct(conid)%Name))
CALL ShowContinueError('Reference Material="'//TRIM(Material(matid)%Name)//'"'// &
' is too thin.')
errorCount=errorCount+1
EXIT
ENDIF
ENDDO
TotCellsMax=TotCellsMax+Material(matid)%divs
ENDDO
TotCellsMax=TotCellsMax+7
ENDDO
IF(errorCount>0)THEN
CALL ShowFatalError('CombinedHeatAndMoistureFiniteElement: Incomplete data to start solution, program terminates.')
ENDIF
! Make the cells and initialise
ALLOCATE(cells(TotCellsMax))
DO ii=1,adjmax
cells%adjs(ii)=-1
cells%adjsl(ii)=-1
ENDDO
cid=0
! Set up surface cell structure
DO sid=1,TotSurfaces
IF (.not. Surface(sid)%HeatTransSurf) CYCLE
IF (Surface(sid)%Class == SurfaceClass_Window) CYCLE
IF (Surface(sid)%HeatTransferAlgorithm /= HeatTransferModel_HAMT) CYCLE
! Boundary Cells
runor=-0.02d0
! Air Convection Cell
cid=cid+1
firstcell(sid)=cid
ExtConcell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
! Air Radiation Cell
cid=cid+1
ExtRadcell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
! Sky Cell
cid=cid+1
ExtSkycell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
! Ground Cell
cid=cid+1
ExtGrncell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
runor=runor+ cells(cid)%length(1)
! External Virtual Cell
cid=cid+1
Extcell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
runor=runor+ cells(cid)%length(1)
! Material Cells
conid=Surface(sid)%Construction
DO lid=1,Construct(conid)%TotLayers
matid=Construct(conid)%LayerPoint(lid)
DO did=1,Material(matid)%divs
cid=cid+1
cells(cid)%matid=matid
cells(cid)%sid=sid
cells(cid)%temp=Material(matid)%itemp
cells(cid)%tempp1=Material(matid)%itemp
cells(cid)%tempp2=Material(matid)%itemp
cells(cid)%rh=Material(matid)%irh
cells(cid)%rhp1=Material(matid)%irh
cells(cid)%rhp2=Material(matid)%irh
cells(cid)%density=Material(matid)%Density
cells(cid)%spech=Material(matid)%SpecHeat
! Make cells smaller near the surface
cells(cid)%length(1)=Material(matid)%Thickness* &
((SIN(pi*(-REAL(did,r64)/REAL(Material(matid)%divs,r64))-pi/2.0d0)/2.0d0)- &
(SIN(pi*(-REAL(did-1,r64)/REAL(Material(matid)%divs,r64))-pi/2.0d0)/2.0d0))
cells(cid)%origin(1)=runor+cells(cid)%length(1)/2.0d0
runor=runor+cells(cid)%length(1)
cells(cid)%volume=cells(cid)%length(1)*Surface(sid)%Area
ENDDO
ENDDO
! Interior Virtual Cell
cid=cid+1
Intcell(sid)=cid
cells(cid)%sid=sid
cells(cid)%rh=0.0d0
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)=cells(cid)%length(1)/2.0d0+runor
runor=runor+ cells(cid)%length(1)
! Air Convection Cell
cid=cid+1
lastcell(sid)=cid
IntConcell(sid)=cid
cells(cid)%rh=0.0d0
cells(cid)%sid=sid
cells(cid)%length(1)=0.01d0
cells(cid)%origin(1)= cells(cid)%length(1)/2.0d0+runor
ENDDO
! Find adjacent cells.
DO cid1=1,TotCellsMax
DO cid2=1,TotCellsMax
IF((cid1/=cid2).AND.(cells(cid1)%sid==cells(cid2)%sid))THEN
high1=cells(cid1)%origin(1)+cells(cid1)%length(1)/2.0d0
low2=cells(cid2)%origin(1)-cells(cid2)%length(1)/2.0d0
IF(ABS(low2-high1)<adjdist)THEN
adj1=0
DO ii=1,adjmax
adj1=adj1+1
IF(cells(cid1)%adjs(adj1)==-1)EXIT
END DO
adj2=0
DO ii=1,adjmax
adj2=adj2+1
IF(cells(cid2)%adjs(adj2)==-1)EXIT
END DO
cells(cid1)%adjs(adj1)=cid2
cells(cid2)%adjs(adj2)=cid1
cells(cid1)%adjsl(adj1)=adj2
cells(cid2)%adjsl(adj2)=adj1
sid=cells(cid1)%sid
cells(cid1)%overlap(adj1)=Surface(sid)%Area
cells(cid2)%overlap(adj2)=Surface(sid)%Area
cells(cid1)%dist(adj1)=cells(cid1)%length(1)/2.0d0
cells(cid2)%dist(adj2)=cells(cid2)%length(1)/2.0d0
ENDIF
ENDIF
ENDDO
ENDDO
! Reset surface virtual cell origins and volumes. Initialise report variables.
WRITE(OutputFileInits,1966)
1966 FORMAT('! <HAMT cells>, Surface Name, Construction Name, Cell Numbers')
WRITE(OutputFileInits,1965)
1965 FORMAT('! <HAMT origins>, Surface Name, Construction Name, Cell origins (m) ')
!cCurrentModuleObject='MaterialProperty:HeatAndMoistureTransfer:*'
DO sid=1,TotSurfaces
IF (.not. Surface(sid)%HeatTransSurf) CYCLE
IF (Surface(sid)%Class == SurfaceClass_Window) CYCLE
IF (Surface(sid)%HeatTransferAlgorithm /= HeatTransferModel_HAMT) CYCLE
cells(Extcell(sid))%origin(1)=cells(Extcell(sid))%origin(1)+cells(Extcell(sid))%length(1)/2.0d0
cells(Intcell(sid))%origin(1)=cells(Intcell(sid))%origin(1)-cells(Intcell(sid))%length(1)/2.0d0
cells(Extcell(sid))%volume=0.0d0
cells(Intcell(sid))%volume=0.0d0
watertot(sid)=0.0d0
surfrh(sid)=0.0d0
surfextrh(sid)=0.0d0
surftemp(sid)=0.0d0
surfexttemp(sid)=0.0d0
surfvp(sid)=0.0d0
CALL SetUpOutputVariable('HAMT Surface Average Water Content Ratio [kg/kg]',watertot(sid), &
'Zone','State',Surface(sid)%Name)
CALL SetUpOutputVariable('HAMT Surface Inside Face Temperature [C]',surftemp(sid), &
'Zone','State',Surface(sid)%Name)
CALL SetUpOutputVariable('HAMT Surface Inside Face Relative Humidity [%]',surfrh(sid), &
'Zone','State',Surface(sid)%Name)
CALL SetUpOutputVariable('HAMT Surface Inside Face Vapor Pressure [Pa]',surfvp(sid), &
'Zone','State',Surface(sid)%Name)
CALL SetUpOutputVariable('HAMT Surface Outside Face Temperature [C]',surfexttemp(sid), &
'Zone','State',Surface(sid)%Name)
CALL SetUpOutputVariable('HAMT Surface Outside Face Relative Humidity [%]',surfextrh(sid), &
'Zone','State',Surface(sid)%Name)
! write cell origins to initilisation output file
conid=Surface(sid)%Construction
WRITE(OutputFileInits,1968) TRIM(Surface(sid)%Name),TRIM(Construct(conid)%Name), &
(concell, concell=1,Intcell(sid)-Extcell(sid)+1)
1968 FORMAT('HAMT cells, ',A,',',A,400(:,',',i4))
WRITE(OutputFileInits,1967) TRIM(Surface(sid)%Name),TRIM(Construct(conid)%Name), &
cells(Extcell(sid):Intcell(sid))%origin(1)
1967 FORMAT('HAMT origins,',A,',',A,400(:,',',f10.7))
concell=1
DO cid=Extcell(sid),Intcell(sid)
CALL SetUpOutputVariable( &
'HAMT Surface Temperature Cell ' &
//TRIM(TrimSigDigits(concell))//' [C]', &
cells(cid)%temp,'Zone','State',Surface(sid)%Name)
concell=concell+1
ENDDO
concell=1
DO cid=Extcell(sid),Intcell(sid)
CALL SetUpOutputVariable( &
'HAMT Surface Water Content Cell ' &
//TRIM(TrimSigDigits(concell))//' [kg/kg]', &
cells(cid)%wreport,'Zone','State',Surface(sid)%Name)
concell=concell+1
ENDDO
concell=1
DO cid=Extcell(sid),Intcell(sid)
CALL SetUpOutputVariable( &
'HAMT Surface Relative Humidity Cell ' &
//TRIM(TrimSigDigits(concell))//' [%]', &
cells(cid)%rhp,'Zone','State',Surface(sid)%Name)
concell=concell+1
ENDDO
ENDDO
CALL ScanForReports('Constructions',DoReport,'Constructions')
IF (DoReport) THEN
WRITE(OutputFileInits,108)
Do MaterNum=1,TotMaterials
WRITE(OutputFileInits,111) Trim(Material(MaterNum)%Name),TRIM(RoundSigDigits(NominalR(MaterNum),4))
end do
End If
108 FORMAT('! <Material Nominal Resistance>, Material Name, Nominal R')
111 FORMAT('Material Nominal Resistance',2(',',A))
END SUBROUTINE InitHeatBalHAMT