SUBROUTINE InitGlassOpticalCalculations
! SUBROUTINE INFORMATION:
! AUTHOR F. Winkelmann
! DATE WRITTEN August 1999
! MODIFIED May 2001 (FW): add window blinds
! Jan 2002 (FW): add blinds with variable slat angle
! Jan 2003 (FW): add between-glass shade/blind
! May 2006 (RR): add exterior window screen
! Aug 2010 (TH): allow spectral data for between-glass shade/blind
! Aug 2013 (TH): allow user defined solar and visible spectrum data
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Manages the calculation of the solar and visible properties of a multi-layer glazing
! system from the properties of the individual glazing and shading layers
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE Vectors
USE General, ONLY: TrimSigDigits
USE WindowEquivalentLayer, ONLY: InitEquivalentLayerWindowCalculations
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 :: CoefNum ! Polynomial coefficient number
INTEGER :: j ! Wavelength counter
INTEGER :: TotLay ! Total solid and gas layers in a window construction
INTEGER :: ConstrNum ! Construction number
INTEGER :: ConstrNumSh ! Shaded construction number
INTEGER :: SurfNum ! Surface number
INTEGER :: ShadeLayNum ! Layer number for shade or blind, if present
INTEGER :: ShadeLayPtr ! Material number for shade or blind
LOGICAL :: lquasi ! True if one or more glass layers have no spectral data
LOGICAL :: AllGlassIsSpectralAverage ! True if all glazing in a construction is spectral average
LOGICAL :: IntShade,ExtShade,BGShade ! True if construction has an interior,exterior or between-glass shade
LOGICAL :: IntBlind,ExtBlind,BGBlind ! True if construction has an interior,exterior or between-glass blind
LOGICAL :: ExtScreen ! True if construction has an exterior screen
LOGICAL :: ScreenOn ! True if construction has an exterior screen
LOGICAL :: BlindOn ! True if IntBlind, ExtBlind or BGBlind is true
LOGICAL :: ShadeOn ! True if IntShade, ExtShade or BGShade is true
INTEGER :: BlNum ! Blind number
INTEGER :: ScNum ! Screen number
REAL(r64) :: sabsPhi(nume) ! Glazing system absorptance for a glass layer
! and angle of incidence, for each wavelength
! glass layer for an angle of incidence, for each wavelength
REAL(r64) :: solabsDiff(5) ! Glazing system layer solar absorptance for each glass layer
REAL(r64) :: solabsPhiLay(10) ! Glazing system solar absorptance for a layer at each incidence angle
REAL(r64) :: tsolPhiFit(10) ! Glazing system solar transmittance from fit at each incidence angle
REAL(r64) :: tvisPhiFit(10) ! Glazing system visible transmittance from fit at each incidence angle
REAL(r64) :: tBareSolPhi(10,5) ! Isolated glass solar transmittance for each incidence angle
REAL(r64) :: t1,t2 ! = tBareSolPhi(,1)(,2)
REAL(r64) :: tBareVisPhi(10,5) ! Isolated glass visible transmittance for each incidence angle
REAL(r64) :: t1v,t2v ! = tBareVisPhi(,1)(,2)
REAL(r64) :: rfBareSolPhi(10,5) ! Isolated glass front solar reflectance for each incidence angle
REAL(r64) :: rfBareVisPhi(10,5) ! Isolated glass front visible reflectance for each incidence angle
REAL(r64) :: rbBareSolPhi(10,5) ! Isolated glass back solar reflectance for each incidence angle
REAL(r64) :: rbBareVisPhi(10,5) ! Isolated glass back visible reflectance for each incidence angle
REAL(r64) :: afBareSolPhi(10,5) ! Isolated glass front solar absorptance for each incidence angle
REAL(r64) :: af1,af2 ! = afBareSolPhi(,1)(,2)
REAL(r64) :: rbmf2 ! Isolated glass #2 front beam reflectance
REAL(r64) :: abBareSolPhi(10,5) ! Isolated glass back solar absorptance for each incidence angle
REAL(r64) :: ab1,ab2 ! = abBareSolPhi(,1)(,2)
REAL(r64) :: td1,td2,td3 ! Isolated glass diffuse solar transmittance
REAL(r64) :: td1v,td2v,td3v ! Isolated glass diffuse visible transmittance
REAL(r64) :: rf1,rf2,rf3 ! Isolated glass diffuse solar front reflectance
REAL(r64) :: rf1v,rf2v,rf3v ! Isolated glass diffuse visible front reflectance
REAL(r64) :: rb1,rb2,rb3 ! Isolated glass diffuse solar back reflectance
REAL(r64) :: rb1v,rb2v,rb3v ! Isolated glass diffuse visible back reflectance
REAL(r64) :: afd1,afd2,afd3 ! Isolated glass diffuse solar front absorptance
REAL(r64) :: abd1,abd2,abd3 ! Isolated glass diffuse solar back absorptance
REAL(r64) :: TauShIR ! IR transmittance of isolated shade
REAL(r64) :: EpsShIR ! IR absorptance of isolated shade
REAL(r64) :: RhoShIR ! IR reflectance of isolated shade
REAL(r64) :: EpsGlIR ! IR absorptance of front or back of isolated glass
REAL(r64) :: RhoGlIR ! IR reflectance of inside face of inside glass
INTEGER :: NGlass ! Number of glass layers in a construction
INTEGER :: IGlass ! Glass layer counter
INTEGER :: LayNum ! Layer number for a glass layer
INTEGER :: LayPtr ! Material number corresponding to LayNum
INTEGER :: IPhi ! Incidence angle counter
REAL(r64) :: Phi ! Incidence angle (deg)
REAL(r64) :: CosPhi ! Cosine of incidence angle
INTEGER :: ILam ! Wavelength counter
REAL(r64) :: tsolDiff ! Glazing system diffuse solar transmittance
REAL(r64) :: tvisDiff ! Glazing system diffuse visible transmittance
INTEGER :: IGlassBack ! Glass layer number counted from back of window
REAL(r64) :: ShadeAbs ! Solar absorptance of isolated shade
REAL(r64) :: ash ! = ShadeAbs
REAL(r64) :: afsh ! Diffuse solar front absorptance of isolated blind
REAL(r64) :: afshGnd,afshSky ! Ground and sky diffuse solar front absorptance of isolated blind
REAL(r64) :: absh ! Diffuse solar back absorptance of isolated blind
REAL(r64) :: ShadeTrans ! Solar transmittance of isolated shade/blind
REAL(r64) :: ShadeTransGnd ! Diffuse-diffuse transmittance of isolated vertical blind with
! horizontal slats for isotropic ground solar
REAL(r64) :: ShadeTransSky ! Diffuse-diffuse transmittance of isolated vertical blind with
! horizontal slats for isotropic sky solar
REAL(r64) :: tsh ! = ShadeTrans
REAL(r64) :: tshGnd,tshSky ! = ShadeTransGnd,ShadeTransSky
REAL(r64) :: tsh2 ! = tsh**2
REAL(r64) :: ShadeRefl ! Solar reflectance of isolated shade
REAL(r64) :: ShadeReflGnd ! Front blind reflectance for ground diffuse solar
REAL(r64) :: ShadeReflSky ! Front blind reflectance for sky diffuse solar
REAL(r64) :: rsh ! = ShadeRefl
REAL(r64) :: rfsh ! Diffuse solar front reflectance of isolated blind
REAL(r64) :: rfshGnd,rfshSky ! Ground and sky diffuse solar front reflectance of isolated blind
REAL(r64) :: rbsh ! Diffuse solar back reflectance of isolated blind
REAL(r64) :: ShadeReflFac ! Shade/blind solar reflection factor
REAL(r64) :: ShadeTransVis ! Visible transmittance of isolated shade/blind
REAL(r64) :: tshv ! = ShadeTransVis
REAL(r64) :: tshv2 ! = tshv**2
REAL(r64) :: ShadeReflVis ! Visible reflectance of isolated shade
REAL(r64) :: rshv ! = ShadeReflVis
REAL(r64) :: rfshv ! Diffuse visible front reflectance of isolated blind
REAL(r64) :: rbshv ! Diffuse visible back reflectance of isolated blind
REAL(r64) :: ShadeReflFacVis ! Shade/blind visible reflection factor
INTEGER :: SpecDataNum ! Spectral data set number
INTEGER :: numptDAT ! Number of wavelengths in a spectral data set
INTEGER :: ISlatAng ! Slat angle counter
LOGICAL :: StormWinConst ! True if a construction with a storm window
LOGICAL :: Triangle ! True if window is triangular
LOGICAL :: Rectangle ! True if window is rectangular
REAL(r64) :: W1(3),W2(3),W3(3) ! Window vertices (m)
REAL(r64) :: W21(3),W23(3) ! W1-W2, W3-W2, resp. (m)
LOGICAL :: lSimpleGlazingSystem = .FALSE. ! true if using simple glazing system block model
REAL(r64) :: SimpleGlazingSHGC = 0.0D0 ! value of SHGC for simple glazing system block model
REAL(r64) :: SimpleGlazingU = 0.0D0 ! value of U-factor for simple glazing system block model
LOGICAL :: BGFlag = .FALSE. ! True if between-glass shade or blind
REAL(r64) :: tmpTrans = 0.0D0 ! solar transmittance calculated from spectral data
REAL(r64) :: tmpTransVis = 0.0D0 ! visible transmittance calculated from spectral data
REAL(r64) :: tmpReflectSolBeamFront = 0.0D0
REAL(r64) :: tmpReflectSolBeamBack =0.0D0
REAL(r64) :: tmpReflectVisBeamFront = 0.0D0
REAL(r64) :: tmpReflectVisBeamBack = 0.0D0
!Debug
INTEGER :: Idb
REAL(r64),DIMENSION(11) :: DbgTheta = (/ 0.d0,10.d0,20.d0,30.d0,40.d0,50.d0,60.d0,70.d0,80.d0,82.5d0,89.5d0 /)
REAL(r64),DIMENSION(11) :: DbgTSol =0.0d0
REAL(r64),DIMENSION(11) :: DbgRbSol =0.0d0
REAL(r64),DIMENSION(11) :: DbgTVis =0.0d0
REAL(r64),DIMENSION(11,5) :: DbgFtAbs =0.0d0
REAL(r64),DIMENSION(11,5) :: DbgBkAbs =0.0d0
REAL(r64) :: DbgTSolDiff =0.0d0
REAL(r64) :: DbgRBSolDiff =0.0d0
REAL(r64),DIMENSION(5) :: DbgFTAbsDiff =0.0d0
REAL(r64),DIMENSION(5) :: DbgBkAbsDiff =0.0d0
!EndDebug
! check and read custom solar and/or visible spectrum data if any
CALL CheckAndReadCustomSprectrumData
CALL W5InitGlassParameters
! Calculate optical properties of blind-type layers entered with MATERIAL:WindowBlind
IF(TotBlinds > 0) CALL CalcWindowBlindProperties
! Initialize SurfaceScreen structure
IF(NumSurfaceScreens > 0) CALL CalcWindowScreenProperties
! Get glazing system optical properties of constructions with glass or glass plus
! shade, screen or blind
! Loop over constructions and find those that are glazing constructions
DO ConstrNum = 1,TotConstructs
IF (.not. Construct(ConstrNum)%TypeIsWindow) CYCLE
IF ( Construct(ConstrNum)%WindowTypeBSDF ) CYCLE !Skip Complex Fenestrations, they have separate
IF ( Construct(ConstrNum)%WindowTypeEQL ) CYCLE !skip Equivalent Layer Fenestration
!handling of optical properties
TotLay = Construct(ConstrNum)%TotLayers
! First layer must be glass, shade, screen or blind to be a glazing construction
IF(Material(Construct(ConstrNum)%LayerPoint(1))%Group /= WindowGlass .AND. &
Material(Construct(ConstrNum)%LayerPoint(1))%Group /= Shade .AND. &
Material(Construct(ConstrNum)%LayerPoint(1))%Group /= Screen .AND. &
Material(Construct(ConstrNum)%LayerPoint(1))%Group /= WindowBlind .AND. &
Material(Construct(ConstrNum)%LayerPoint(1))%Group /= WindowSimpleGlazing) CYCLE
ShadeLayNum = 0
ExtShade = .FALSE.
IntShade = .FALSE.
BGShade = .FALSE.
ExtBlind = .FALSE.
IntBlind = .FALSE.
BGBlind = .FALSE.
ExtScreen = .FALSE.
StormWinConst = .false.
lSimpleGlazingSystem = .FALSE.
IF (Material(Construct(ConstrNum)%LayerPoint(1))%Group == WindowSimpleGlazing) Then
! what if outside layer is shade, blind, or screen?
lSimpleGlazingSystem = .TRUE.
SimpleGlazingSHGC = Material(Construct(ConstrNum)%LayerPoint(1))%SimpleWindowSHGC
SimpleGlazingU = Material(Construct(ConstrNum)%LayerPoint(1))%SimpleWindowUfactor
ENDIF
IF(Construct(ConstrNum)%Name(1:28)=='BARECONSTRUCTIONWITHSTORMWIN' .OR. &
Construct(ConstrNum)%Name(1:30)=='SHADEDCONSTRUCTIONWITHSTORMWIN') StormWinConst = .true.
! Get layer number of shade/blind
IF(Material(Construct(ConstrNum)%LayerPoint(1))%Group == Shade) THEN
ExtShade = .TRUE.
ShadeLayNum = 1
ELSE IF(Material(Construct(ConstrNum)%LayerPoint(TotLay))%Group == Shade) THEN
IntShade = .TRUE.
ShadeLayNum = TotLay
ELSE IF(Construct(ConstrNum)%TotLayers == 5) THEN
IF (Material(Construct(ConstrNum)%LayerPoint(3))%Group == Shade) THEN
BGShade = .TRUE.
ShadeLayNum = 3
ENDIF
ELSE IF(Construct(ConstrNum)%TotLayers == 7) THEN
IF (Material(Construct(ConstrNum)%LayerPoint(5))%Group == Shade) THEN
BGShade = .TRUE.
ShadeLayNum = 5
ENDIF
ENDIF
IF(Material(Construct(ConstrNum)%LayerPoint(1))%Group == WindowBlind) THEN
ExtBlind = .TRUE.
ShadeLayNum = 1
BlNum = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%BlindDataPtr
ELSE IF(Material(Construct(ConstrNum)%LayerPoint(TotLay))%Group == WindowBlind) THEN
IntBlind = .TRUE.
ShadeLayNum = TotLay
BlNum = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%BlindDataPtr
ELSE IF(Construct(ConstrNum)%TotLayers == 5) THEN
IF (Material(Construct(ConstrNum)%LayerPoint(3))%Group == WindowBlind) THEN
BGBlind = .TRUE.
ShadeLayNum = 3
BlNum = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%BlindDataPtr
ENDIF
ELSE IF(Construct(ConstrNum)%TotLayers == 7) THEN
IF (Material(Construct(ConstrNum)%LayerPoint(5))%Group == WindowBlind) THEN
BGBlind = .TRUE.
ShadeLayNum = 5
BlNum = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%BlindDataPtr
ENDIF
END IF
IF(Material(Construct(ConstrNum)%LayerPoint(1))%Group == Screen) THEN
ShadeLayNum = 1
ScNum = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%ScreenDataPtr
! Disregard orphaned constructs with exterior screen
IF(ScNum .EQ. 0)CYCLE
ExtScreen = .TRUE.
END IF
ScreenOn = ExtScreen
BlindOn = IntBlind.OR.ExtBlind.OR.BGBlind
ShadeOn = IntShade.OR.ExtShade.OR.BGShade
BGFlag = BGBlind.OR.BGShade
! For construction with interior or exterior shade, get shade thermal absorptance (emissivity)
! (accounting for inter-reflection with glazing) and correct the inside glass InsideAbsorpThermal
! for presence of interior shade. Assumes inner and outer glass layers have zero thermal transmittance.
IF(IntShade.OR.ExtShade.OR.ExtScreen) THEN
ShadeLayPtr = Construct(ConstrNum)%LayerPoint(ShadeLayNum)
IF(ExtScreen)THEN
TauShIR = SurfaceScreens(ScNum)%DifDifTrans
ELSE
TauShIR = Material(ShadeLayPtr)%TransThermal
ENDIF
EpsShIR = Material(ShadeLayPtr)%AbsorpThermal
RhoShIR = MAX(0.0d0,1.d0-TauShIR-EpsShIR)
IF(ExtShade .OR. ExtScreen) THEN ! Exterior shade or screen
EpsGlIR = Material(Construct(ConstrNum)%LayerPoint(2))%AbsorpThermalFront
ELSE ! Interior shade
EpsGlIR = Material(Construct(ConstrNum)%LayerPoint(TotLay-1))%AbsorpThermalBack
END IF
RhoGlIR = MAX(0.0d0,1.d0-EpsGlIR)
Construct(ConstrNum)%ShadeAbsorpThermal = EpsShIR*(1.d0+TauShIR*RhoGlIR/(1.d0-RhoShIR*RhoGlIR))
IF(IntShade) Construct(ConstrNum)%InsideAbsorpThermal = &
Construct(ConstrNum)%InsideAbsorpThermal*TauShIR/(1.d0-RhoShIR*RhoGlIR)
END IF
! From the individual glass layer properties, get the glazing system optical properties
! for BARE GLASS (i.e., interior, exterior or between-glass shade or blind, or exterior screen, if present, not in place).
! Get one set of system properties for solar incident on front of
! window and a second set for solar incident on back of window. (The back-incident
! properties are used with interior short-wave radiation striking the window from inside.)
! After the front and back system optical properties are calculated for bare glass,
! a correction is made for the effect of a shade, screen or blind if one of these
! is present in the construction.
NGlass = Construct(ConstrNum)%TotGlassLayers
!--------------------------------------------------------------------------------------------
! Front calculation (solar incident from outside of room); bare glass portion of construction
!--------------------------------------------------------------------------------------------
lquasi = .FALSE.
AllGlassIsSpectralAverage = .TRUE.
! Loop over glass layers in the construction
DO IGlass = 1,NGlass
LayNum = 1 + 2*(IGlass-1)
IF(ExtShade.OR.ExtBlind.OR.ExtScreen) LayNum = 2 + 2*(IGlass-1)
IF(BGShade.OR.BGBlind) THEN
LayNum = 1
IF(NGlass==2) THEN
IF(IGlass==2) LayNum = 5
ELSE ! NGlass = 3
IF(IGlass==2) LayNum = 3
IF(IGlass==3) LayNum = 7
END IF
END IF
LayPtr = Construct(ConstrNum)%LayerPoint(LayNum)
SpecDataNum = Material(LayPtr)%GlassSpectralDataPtr
IF(SpecDataNum /= 0) THEN
IF (.NOT. BGFlag) AllGlassIsSpectralAverage = .FALSE.
! Get the spectral data for the transmittance, front reflectance and
! back reflectance (all at normal incidence) for this layer.
! In this case, "front" means incident from the outside and "back"
! means incident from the inside.
numptDAT = SpectralData(SpecDataNum)%NumOfWavelengths
numpt(IGlass) = numptDat
DO ILam = 1,numptDat
wlt(ILam,IGlass) = SpectralData(SpecDataNum)%Wavelength(ILam)
t(ILam,IGlass) = SpectralData(SpecDataNum)%Trans(ILam)
IF((IGlass==1.OR.(IGlass==2.AND.StormWinConst)).AND.(.NOT.BGFlag)) t(ILam,IGlass) = &
t(ILam,IGlass) * Material(LayPtr)%GlassTransDirtFactor
rff(ILam,IGlass) = SpectralData(SpecDataNum)%ReflFront(ILam)
rbb(ILam,IGlass) = SpectralData(SpecDataNum)%ReflBack(ILam)
END DO
! TH 8/26/2010, CR 8206
! If there is spectral data for between-glass shades or blinds, calc the average spectral properties for use.
IF (BGFlag) THEN
! 5/16/2012 CR 8793. Add warning message for the glazing defined with full spectral data.
CALL ShowWarningError('Window glazing material "'//TRIM(Material(LayPtr)%Name)// &
'" was defined with full spectral data and has been converted to average spectral data')
CALL ShowContinueError('due to its use with between-glass shades or blinds of the window construction "'// &
TRIM(Construct(ConstrNum)%Name) // '".')
CALL ShowContinueError('All occurrences of this glazing material will be modeled as SpectralAverage.')
CALL ShowContinueError('If this material is also used in other window constructions'// &
' without between-glass shades or blinds,')
CALL ShowContinueError('then make a duplicate material (with new name) if you want to model those windows '// &
' (and reference the new material) using the full spectral data.')
! calc Trans, TransVis, ReflectSolBeamFront, ReflectSolBeamBack, ReflectVisBeamFront, ReflectVisBeamBack
! assuming wlt same as wle
CALL SolarSprectrumAverage(t, tmpTrans)
CALL SolarSprectrumAverage(rff, tmpReflectSolBeamFront)
CALL SolarSprectrumAverage(rbb, tmpReflectSolBeamBack)
! visible properties
CALL VisibleSprectrumAverage(t, tmpTransVis)
CALL VisibleSprectrumAverage(rff, tmpReflectVisBeamFront)
CALL VisibleSprectrumAverage(rbb, tmpReflectVisBeamBack)
! set this material to average spectral data
Material(LayPtr)%GlassSpectralDataPtr = 0
Material(LayPtr)%Trans = tmpTrans
Material(LayPtr)%TransVis = tmpTransVis
Material(LayPtr)%ReflectSolBeamFront = tmpReflectSolBeamFront
Material(LayPtr)%ReflectSolBeamBack = tmpReflectSolBeamBack
Material(LayPtr)%ReflectVisBeamFront = tmpReflectVisBeamFront
Material(LayPtr)%ReflectVisBeamBack = tmpReflectVisBeamBack
SpecDataNum = 0
ENDIF
ENDIF
IF(SpecDataNum == 0) THEN ! No spectral data for this layer; use spectral average values
lquasi = .TRUE.
numpt(IGlass) = 2
t(1,IGlass) = Material(LayPtr)%Trans
IF(IGlass==1.OR.(IGlass==2.AND.StormWinConst)) t(1,IGlass) = &
t(1,IGlass) * Material(LayPtr)%GlassTransDirtFactor
t(2,IGlass) = Material(LayPtr)%TransVis
IF(IGlass==1.OR.(IGlass==2.AND.StormWinConst)) t(2,IGlass) = &
t(2,IGlass) * Material(LayPtr)%GlassTransDirtFactor
rff(1,IGlass) = Material(LayPtr)%ReflectSolBeamFront
rbb(1,IGlass) = Material(LayPtr)%ReflectSolBeamBack
rff(2,IGlass) = Material(LayPtr)%ReflectVisBeamFront
rbb(2,IGlass) = Material(LayPtr)%ReflectVisBeamBack
END IF
END DO ! End of loop over glass layers in the construction for front calculation
! Loop over incidence angle from 0 to 90 deg in 10 deg increments.
! Get glass layer properties, then glazing system properties (which include the
! effect of inter-reflection among glass layers) at each incidence angle.
DO IPhi = 1,10
Phi = REAL(IPhi-1,r64)*10.d0
CosPhi = COS(Phi*DegToRadians)
if (abs(CosPhi) < .0001d0) CosPhi=0.0d0
! For each wavelength, get glass layer properties at this angle of incidence
! from properties at normal incidence
DO IGlass = 1,NGlass
DO ILam = 1,numpt(IGlass)
CALL TransAndReflAtPhi(CosPhi,t(ILam,IGlass),rff(ILam,IGlass),rbb(ILam,IGlass), &
tPhi(ILam,IGlass),rfPhi(ILam,IGlass),rbPhi(ILam,IGlass), &
lSimpleGlazingSystem, SimpleGlazingSHGC, SimpleGlazingU)
END DO
! For use with between-glass shade/blind, save angular properties of isolated glass
! for case that all glass layers were input with spectral-average properties
! only used by between-glass shades or blinds
IF(AllGlassIsSpectralAverage) THEN
tBareSolPhi(IPhi,IGlass) = tPhi(1,IGlass)
tBareVisPhi(IPhi,IGlass) = tPhi(2,IGlass)
rfBareSolPhi(IPhi,IGlass) = rfPhi(1,IGlass)
rfBareVisPhi(IPhi,IGlass) = rfPhi(2,IGlass)
rbBareSolPhi(IPhi,IGlass) = rbPhi(1,IGlass)
rbBareVisPhi(IPhi,IGlass) = rbPhi(2,IGlass)
afBareSolPhi(IPhi,IGlass) = MAX(0.0d0,1.d0-(tBareSolPhi(IPhi,IGlass)+rfBareSolPhi(IPhi,IGlass)))
abBareSolPhi(IPhi,IGlass) = MAX(0.0d0,1.d0-(tBareSolPhi(IPhi,IGlass)+rbBareSolPhi(IPhi,IGlass)))
END IF
END DO
! For each wavelength in the solar spectrum, calculate system properties
! stPhi, srfPhi, srbPhi and saPhi at this angle of incidence.
! In the following the argument "1" indicates that spectral average solar values
! should be used for layers without spectral data.
CALL SystemSpectralPropertiesAtPhi(1,NGlass,0.0d0,2.54d0)
! Get solar properties of system by integrating over solar irradiance spectrum.
! For now it is assumed that the exterior and interior irradiance spectra are the same.
CALL SolarSprectrumAverage(stPhi, tsolPhi(IPhi))
CALL SolarSprectrumAverage(srfPhi,rfsolPhi(IPhi))
CALL SolarSprectrumAverage(srbPhi,rbsolPhi(IPhi))
DO IGlass = 1, NGlass
DO ILam = 1, nume
sabsPhi(ILam) = saPhi(ILam,IGlass)
END DO
CALL SolarSprectrumAverage(sabsPhi,solabsPhi(IPhi,IGlass))
END DO
! Get visible properties of system by integrating over solar irradiance
! spectrum weighted by photopic response.
! Need to redo the calculation of system spectral properties here only if
! one or more glass layers have no spectral data (lquasi = .TRUE.); in this
! case the spectral average visible properties will be used for the layers
! without spectral data, as indicated by the argument "2".
if (lquasi) CALL SystemSpectralPropertiesAtPhi(2,NGlass,0.37d0,0.78d0)
CALL VisibleSprectrumAverage(stPhi, tvisPhi(IPhi))
CALL VisibleSprectrumAverage(srfPhi, rfvisPhi(IPhi))
CALL VisibleSprectrumAverage(srbPhi, rbvisPhi(IPhi))
END DO ! End of loop over incidence angles for front calculation
! only used by between-glass shades or blinds
IF(AllGlassIsSpectralAverage) THEN
DO IGlass = 1,NGlass
CALL W5LsqFit(CosPhiIndepVar,tBareSolPhi (:,IGlass),6,1,10,Construct(ConstrNum)%tBareSolCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,tBareVisPhi (:,IGlass),6,1,10,Construct(ConstrNum)%tBareVisCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,rfBareSolPhi(:,IGlass),6,1,10,Construct(ConstrNum)%rfBareSolCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,rfBareVisPhi(:,IGlass),6,1,10,Construct(ConstrNum)%rfBareVisCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,rbBareSolPhi(:,IGlass),6,1,10,Construct(ConstrNum)%rbBareSolCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,rbBareVisPhi(:,IGlass),6,1,10,Construct(ConstrNum)%rbBareVisCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,afBareSolPhi(:,IGlass),6,1,10,Construct(ConstrNum)%afBareSolCoef(IGlass,:))
CALL W5LsqFit(CosPhiIndepVar,abBareSolPhi(:,IGlass),6,1,10,Construct(ConstrNum)%abBareSolCoef(IGlass,:))
END DO
END IF
Construct(ConstrNum)%ReflectSolDiffFront = DiffuseAverage(rfsolPhi)
Construct(ConstrNum)%ReflectSolDiffBack = DiffuseAverage(rbsolPhi)
Construct(ConstrNum)%ReflectVisDiffFront = DiffuseAverage(rfvisPhi)
Construct(ConstrNum)%ReflectVisDiffBack = DiffuseAverage(rbvisPhi)
tsolDiff = DiffuseAverage(tsolPhi)
tvisDiff = DiffuseAverage(tvisPhi)
Construct(ConstrNum)%TransDiff = tsolDiff
Construct(ConstrNum)%TransDiffVis = tvisDiff
DO IGlass = 1,NGlass
solabsPhiLay(1:10) = solabsPhi(1:10,IGlass)
solabsDiff(IGlass) = DiffuseAverage(solabsPhiLay)
Construct(ConstrNum)%AbsDiff(IGlass) = solabsDiff(IGlass)
! For use with between-glass shade/blind, get diffuse properties of isolated glass for case when
! all glass layers were input with spectral-average properties
! only used by between-glass shades or blinds
IF(AllGlassIsSpectralAverage) THEN
Construct(ConstrNum)%tBareSolDiff(IGlass) = DiffuseAverage(tBareSolPhi(1:10,IGlass))
Construct(ConstrNum)%tBareVisDiff(IGlass) = DiffuseAverage(tBareVisPhi(1:10,IGlass))
Construct(ConstrNum)%rfBareSolDiff(IGlass) = DiffuseAverage(rfBareSolPhi(1:10,IGlass))
Construct(ConstrNum)%rfBareVisDiff(IGlass) = DiffuseAverage(rfBareVisPhi(1:10,IGlass))
Construct(ConstrNum)%rbBareSolDiff(IGlass) = DiffuseAverage(rbBareSolPhi(1:10,IGlass))
Construct(ConstrNum)%rbBareVisDiff(IGlass) = DiffuseAverage(rbBareVisPhi(1:10,IGlass))
Construct(ConstrNum)%afBareSolDiff(IGlass) = &
MAX(0.0d0,1.d0-(Construct(ConstrNum)%tBareSolDiff(IGlass)+Construct(ConstrNum)%rfBareSolDiff(IGlass)))
Construct(ConstrNum)%abBareSolDiff(IGlass) = &
MAX(0.0d0,1.d0-(Construct(ConstrNum)%tBareSolDiff(IGlass)+Construct(ConstrNum)%rbBareSolDiff(IGlass)))
END IF
END DO
!------------------------------------------------------------------------------------------
! Back calculation (solar incident from inside of room); bare glass portion of construction
!------------------------------------------------------------------------------------------
lquasi = .FALSE.
! Loop over glass layers in the construction.
DO IGlass = 1,NGlass
LayNum = 1 + (NGlass-IGlass)*2
IF(ExtShade.OR.ExtBlind.OR.ExtScreen) LayNum = 2 + (NGlass-IGlass)*2
IF(BGShade.OR.BGBlind) THEN
IF(NGlass==2) THEN
IF(IGlass==1) LayNum = 5
IF(IGlass==2) LayNum = 1
ELSE ! NGlass = 3
IF(IGlass==1) LayNum = 7
IF(IGlass==2) LayNum = 3
IF(IGlass==3) LayNum = 1
END IF
END IF
LayPtr = Construct(ConstrNum)%LayerPoint(LayNum)
SpecDataNum = Material(LayPtr)%GlassSpectralDataPtr
IF(SpecDataNum /= 0) THEN
! Get the spectral data for the transmittance, front reflectance and
! back reflectance (all at normal incidence) for this layer.
! In this case, "front" means incident from the inside and "back"
! means incident from the outside.
numptDAT = SpectralData(SpecDataNum)%NumOfWavelengths
numpt(IGlass) = numptDat
DO ILam = 1,numptDat
wlt(ILam,IGlass) = SpectralData(SpecDataNum)%Wavelength(ILam)
t(ILam,IGlass) = SpectralData(SpecDataNum)%Trans(ILam)
IF(IGlass==NGlass.OR.(IGlass==(NGlass-1).AND.StormWinConst)) t(ILam,IGlass) = &
t(ILam,IGlass) * Material(LayPtr)%GlassTransDirtFactor
rff(ILam,IGlass) = SpectralData(SpecDataNum)%ReflBack(ILam)
rbb(ILam,IGlass) = SpectralData(SpecDataNum)%ReflFront(ILam)
END DO
ELSE ! No spectral data for this layer; use spectral average values
lquasi = .TRUE.
numpt(IGlass) = 2
t(1,IGlass) = Material(LayPtr)%Trans
IF(IGlass==NGlass.OR.(IGlass==(NGlass-1).AND.StormWinConst)) t(1,IGlass) = &
t(1,IGlass) * Material(LayPtr)%GlassTransDirtFactor
t(2,IGlass) = Material(LayPtr)%TransVis
IF(IGlass==NGlass.OR.(IGlass==(NGlass-1).AND.StormWinConst)) t(2,IGlass) = &
t(2,IGlass) * Material(LayPtr)%GlassTransDirtFactor
rff(1,IGlass) = Material(LayPtr)%ReflectSolBeamBack
rbb(1,IGlass) = Material(LayPtr)%ReflectSolBeamFront
rff(2,IGlass) = Material(LayPtr)%ReflectVisBeamBack
rbb(2,IGlass) = Material(LayPtr)%ReflectVisBeamFront
END IF
END DO ! End of loop over glass layers in the construction for back calculation
! Loop over incidence angle from 0 to 90 deg in 10 deg increments.
! Get bare glass layer properties, then glazing system properties at each incidence angle.
! The glazing system properties include the effect of inter-reflection among glass layers,
! but exclude the effect of a shade or blind if present in the construction.
DO IPhi = 1,10
Phi = REAL(IPhi-1,r64)*10.d0
CosPhi = COS(Phi*DegToRadians)
if (abs(CosPhi) < .0001d0) CosPhi=0.0d0
! For each wavelength, get glass layer properties at this angle of incidence
! from properties at normal incidence
DO IGlass = 1,NGlass
DO ILam = 1,numpt(IGlass)
CALL TransAndReflAtPhi(CosPhi,t(ILam,IGlass),rff(ILam,IGlass),rbb(ILam,IGlass), &
tPhi(ILam,IGlass),rfPhi(ILam,IGlass),rbPhi(ILam,IGlass), &
lSimpleGlazingSystem, SimpleGlazingSHGC, SimpleGlazingU)
END DO
END DO
! For each wavelength in the solar spectrum, calculate system properties
! stPhi, srfPhi, srbPhi and saPhi at this angle of incidence
CALL SystemSpectralPropertiesAtPhi(1,NGlass,0.0d0,2.54d0)
! Get back absorptance properties of system by integrating over solar irradiance spectrum.
! For now it is assumed that the exterior and interior irradiance spectra are the same.
DO IGlass=1,NGlass
DO j=1,nume
sabsPhi(j) = saPhi(j,IGlass)
END DO
CALL SolarSprectrumAverage(sabsPhi,solabsBackPhi(IPhi,IGlass))
END DO
END DO ! End of loop over incidence angles for back calculation
DO IGlass = 1,NGlass
IGlassBack = NGlass-IGlass+1
Construct(ConstrNum)%AbsDiffBack(IGlass) = DiffuseAverage(solabsBackPhi(1:10,IGlassBack))
END DO
!-----------------------------------------------------------------------
! Correction for effect of shade, screen or blind if present in the construction
!-----------------------------------------------------------------------
! For construction with shade, screen or blind, get system shading device absorptance
! and correct the system glass layer absorptances for the effect of reflection
! and transmission by shade, screen or blind. Get system reflectance (front and back,
! solar and visible)
IF(ShadeOn.OR.BlindOn.OR.ScreenOn) THEN
! Solar and visible properties of isolated shade or blind
! (Note: for shades or screen we go through the following loop over slat angles only once.)
DO ISlatAng = 1,MaxSlatAngs
IF(ShadeOn) THEN
ShadeAbs = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%AbsorpSolar
ShadeTrans = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%Trans
ShadeTransVis = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%TransVis
ShadeRefl = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%ReflectShade
ShadeReflVis = Material(Construct(ConstrNum)%LayerPoint(ShadeLayNum))%ReflectShadeVis
rsh = ShadeRefl
rshv = ShadeReflVis
tsh = ShadeTrans
tshv = ShadeTransVis
ash = ShadeAbs
ELSE IF(IntBlind.OR.ExtBlind) THEN
ShadeTrans = Blind(BlNum)%SolFrontDiffDiffTrans(ISlatAng)
ShadeTransGnd = Blind(BlNum)%SolFrontDiffDiffTransGnd(ISlatAng)
ShadeTransSky = Blind(BlNum)%SolFrontDiffDiffTransSky(ISlatAng)
ShadeTransVis = Blind(BlNum)%VisFrontDiffDiffTrans(ISlatAng)
IF(IntBlind) THEN ! Interior blind
ShadeAbs = Blind(BlNum)%SolFrontDiffAbs(ISlatAng)
ShadeRefl = Blind(BlNum)%SolFrontDiffDiffRefl(ISlatAng)
ShadeReflGnd = Blind(BlNum)%SolFrontDiffDiffReflGnd(ISlatAng)
ShadeReflSky = Blind(BlNum)%SolFrontDiffDiffReflSky(ISlatAng)
ShadeReflVis = Blind(BlNum)%VisFrontDiffDiffRefl(ISlatAng)
ELSE ! Exterior blind
ShadeAbs = Blind(BlNum)%SolBackDiffAbs(ISlatAng)
ShadeRefl = Blind(BlNum)%SolBackDiffDiffRefl(ISlatAng)
ShadeReflVis = Blind(BlNum)%VisBAckDiffDiffRefl(ISlatAng)
END IF
ELSE IF(BGBlind) THEN
tsh = Blind(BlNum)%SolFrontDiffDiffTrans(ISlatAng)
tshGnd= Blind(BlNum)%SolFrontDiffDiffTransGnd(ISlatAng)
tshSky= Blind(BlNum)%SolFrontDiffDiffTransSky(ISlatAng)
tshv = Blind(BlNum)%VisFrontDiffDiffTrans(ISlatAng)
rfsh = Blind(BlNum)%SolFrontDiffDiffRefl(ISlatAng)
rfshGnd = Blind(BlNum)%SolFrontDiffDiffReflGnd(ISlatAng)
rfshSky = Blind(BlNum)%SolFrontDiffDiffReflSky(ISlatAng)
rfshv = Blind(BlNum)%VisFrontDiffDiffRefl(ISlatAng)
rbsh = Blind(BlNum)%SolBackDiffDiffRefl(ISlatAng)
rbshv = Blind(BlNum)%VisBackDiffDiffRefl(ISlatAng)
afsh = Blind(BlNum)%SolFrontDiffAbs(ISlatAng)
afshGnd = Blind(BlNum)%SolFrontDiffAbsGnd(ISlatAng)
afshSky = Blind(BlNum)%SolFrontDiffAbsSky(ISlatAng)
absh = Blind(BlNum)%SolBackDiffAbs(ISlatAng)
ELSE IF(ScreenOn .AND. ScNum .GT. 0) THEN
! diffuse screen properties are calculated during initialization (quarter-hemispherical integration of beam properties)
ShadeAbs = SurfaceScreens(ScNum)%DifScreenAbsorp
ShadeTrans = SurfaceScreens(ScNum)%DifDifTrans
ShadeTransVis = SurfaceScreens(ScNum)%DifDifTransVis
ShadeRefl = SurfaceScreens(ScNum)%DifReflect
ShadeReflVis = SurfaceScreens(ScNum)%DifReflectVis
rsh = ShadeRefl
rshv = ShadeReflVis
tsh = ShadeTrans
tshv = ShadeTransVis
ash = ShadeAbs
END IF
! Correction factors for inter-reflections between glass and shading device
IF(ExtShade .OR. ExtBlind .OR. ExtScreen) THEN
ShadeReflFac = 1.d0 / (1.d0-ShadeRefl*Construct(ConstrNum)%ReflectSolDiffFront)
ShadeReflFacVis = 1.d0 / (1.d0-ShadeReflVis*Construct(ConstrNum)%ReflectVisDiffFront)
ELSE IF(IntShade .OR. IntBlind) THEN
ShadeReflFac = 1.d0 / (1.d0-ShadeRefl*Construct(ConstrNum)%ReflectSolDiffBack)
ShadeReflFacVis = 1.d0 / (1.d0-ShadeReflVis*Construct(ConstrNum)%ReflectVisDiffBack)
END IF
IF(ExtShade .OR. ExtBlind .OR. ExtScreen) THEN ! Exterior shade or blind
! Front incident solar, beam, exterior shade, screen or blind
IF(ExtShade) THEN
DO IPhi = 1,10
DO IGlass = 1,NGlass
solabsPhi(IPhi,IGlass) = ShadeTrans * solabsDiff(IGlass) * ShadeReflFac
END DO
tsolPhi(IPhi) = ShadeTrans * ShadeReflFac * tsolDiff
tvisPhi(IPhi) = ShadeTransVis * ShadeReflFacVis * tvisDiff
solabsShadePhi(IPhi) = ShadeAbs * &
(1.d0 + ShadeTrans*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffFront)
END DO
END IF
! Front incident solar, diffuse, exterior shade/screen/blind
DO IGlass = 1,NGlass
IF(ExtBlind) THEN
Construct(ConstrNum)%BlAbsDiff(IGlass,ISlatAng) = ShadeTrans * ShadeReflFac * solabsDiff(IGlass)
Construct(ConstrNum)%BlAbsDiffGnd(IGlass,ISlatAng) = ShadeTransGnd * ShadeReflFac * solabsDiff(IGlass)
Construct(ConstrNum)%BlAbsDiffSky(IGlass,ISlatAng) = ShadeTransSky * ShadeReflFac * solabsDiff(IGlass)
END IF
IF(ExtShade .OR. ExtScreen) Construct(ConstrNum)%AbsDiff(IGlass) = ShadeTrans * ShadeReflFac * solabsDiff(IGlass)
END DO
IF(ExtBlind) THEN
Construct(ConstrNum)%AbsDiffBlind(ISlatAng) = Blind(BlNum)%SolFrontDiffAbs(ISlatAng) + &
ShadeTrans*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffFront*ShadeAbs
Construct(ConstrNum)%AbsDiffBlindGnd(ISlatAng) = Blind(BlNum)%SolFrontDiffAbsGnd(ISlatAng) + &
ShadeTransGnd*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffFront*ShadeAbs
Construct(ConstrNum)%AbsDiffBlindSky(ISlatAng) = Blind(BlNum)%SolFrontDiffAbsSky(ISlatAng) + &
ShadeTransSky*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffFront*ShadeAbs
Construct(ConstrNum)%BlTransDiff(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTrans
Construct(ConstrNum)%BlTransDiffGnd(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTransGnd
Construct(ConstrNum)%BlTransDiffSky(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTransSky
Construct(ConstrNum)%BlTransDiffVis(ISlatAng) = tvisDiff * ShadeReflFacVis * ShadeTransVis
Construct(ConstrNum)%BlReflectSolDiffFront(ISlatAng) = ShadeRefl + (ShadeTrans**2) * &
Construct(ConstrNum)%ReflectSolDiffFront * ShadeReflFac
Construct(ConstrNum)%BlReflectVisDiffFront(ISlatAng) = ShadeReflVis + (ShadeTransVis**2) * &
Construct(ConstrNum)%ReflectVisDiffFront * ShadeReflFacVis
END IF
IF(ExtShade .OR. ExtScreen) THEN
Construct(ConstrNum)%AbsDiffShade = ShadeAbs * &
(1.d0 + ShadeTrans*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffFront)
Construct(ConstrNum)%TransDiff = tsolDiff * ShadeReflFac * ShadeTrans
Construct(ConstrNum)%TransDiffVis = tvisDiff * ShadeReflFacVis * ShadeTransVis
Construct(ConstrNum)%ReflectSolDiffFront = ShadeRefl + (ShadeTrans**2) * &
Construct(ConstrNum)%ReflectSolDiffFront * ShadeReflFac
Construct(ConstrNum)%ReflectVisDiffFront = ShadeReflVis + (ShadeTransVis**2) * &
Construct(ConstrNum)%ReflectVisDiffFront * ShadeReflFacVis
END IF
! Back incident solar, diffuse, exterior shade/blind
IF(ExtBlind) THEN
DO IGlass = 1,NGlass
Construct(ConstrNum)%BlAbsDiffBack(IGlass,ISlatAng) = Construct(ConstrNum)%AbsDiffBack(IGlass) + &
tsolDiff * ShadeRefl * ShadeReflFac * solabsDiff(IGlass)
END DO
Construct(ConstrNum)%AbsDiffBackBlind(ISlatAng) = tsolDiff * ShadeReflFac * ShadeAbs
Construct(ConstrNum)%BlReflectSolDiffBack(ISlatAng) = Construct(ConstrNum)%ReflectSolDiffBack + &
(tsolDiff**2) * ShadeRefl * ShadeReflFac
Construct(ConstrNum)%BlReflectVisDiffBack(ISlatAng) = Construct(ConstrNum)%ReflectVisDiffBack + &
(tvisDiff**2) * ShadeReflVis * ShadeReflFacVis
END IF
IF(ExtShade .OR. ExtScreen) THEN
DO IGlass = 1,NGlass
Construct(ConstrNum)%AbsDiffBack(IGlass) = Construct(ConstrNum)%AbsDiffBack(IGlass) + &
tsolDiff * ShadeRefl * ShadeReflFac * solabsDiff(IGlass)
END DO
Construct(ConstrNum)%AbsDiffBackShade = tsolDiff * ShadeReflFac * ShadeAbs
Construct(ConstrNum)%ReflectSolDiffBack = Construct(ConstrNum)%ReflectSolDiffBack + &
(tsolDiff**2) * ShadeRefl * ShadeReflFac
Construct(ConstrNum)%ReflectVisDiffBack = Construct(ConstrNum)%ReflectVisDiffBack + &
(tvisDiff**2) * ShadeReflVis * ShadeReflFacVis
END IF
END IF ! End check if exterior shade, screen or blind
IF(IntShade.OR.IntBlind) THEN ! Interior shade or blind
! Front incident solar, beam, interior shade
IF(IntShade) THEN
DO IPhi = 1,10
DO IGlass = 1,NGlass
solabsPhi(IPhi,IGlass) = solabsPhi(IPhi,IGlass) + &
tsolPhi(IPhi) * ShadeRefl * ShadeReflFac * Construct(ConstrNum)%AbsDiffBack(IGlass)
END DO
solabsShadePhi(IPhi) = tsolPhi(IPhi) * ShadeReflFac * ShadeAbs
tsolPhi(IPhi) = tsolPhi(IPhi) * ShadeReflFac * ShadeTrans
tvisPhi(IPhi) = tvisPhi(IPhi) * ShadeReflFacVis * ShadeTransVis
END DO
END IF ! End of check if interior shade
! Front incident solar, diffuse, interior blind
IF(IntBlind) THEN
DO IGlass = 1,NGlass
Construct(ConstrNum)%BlAbsDiff(IGlass,ISlatAng) = Construct(ConstrNum)%AbsDiff(IGlass) + &
tsolDiff * ShadeRefl * ShadeReflFac * Construct(ConstrNum)%AbsDiffBack(IGlass)
Construct(ConstrNum)%BlAbsDiffGnd(IGlass,ISlatAng) = Construct(ConstrNum)%AbsDiff(IGlass) + &
tsolDiff * ShadeReflGnd * ShadeReflFac * Construct(ConstrNum)%AbsDiffBack(IGlass)
Construct(ConstrNum)%BlAbsDiffsky(IGlass,ISlatAng) = Construct(ConstrNum)%AbsDiff(IGlass) + &
tsolDiff * ShadeReflSky * ShadeReflFac * Construct(ConstrNum)%AbsDiffBack(IGlass)
END DO
Construct(ConstrNum)%AbsDiffBlind(ISlatAng) = tsolDiff * ShadeReflFac * ShadeAbs
Construct(ConstrNum)%AbsDiffBlindGnd(ISlatAng)= tsolDiff * ShadeReflFac * Blind(BlNum)%SolFrontDiffAbsGnd(ISlatAng)
Construct(ConstrNum)%AbsDiffBlindSky(ISlatAng)= tsolDiff * ShadeReflFac * Blind(BlNum)%SolFrontDiffAbsSky(ISlatAng)
Construct(ConstrNum)%BlTransDiff(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTrans
Construct(ConstrNum)%BlTransDiffGnd(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTransGnd
Construct(ConstrNum)%BlTransDiffSky(ISlatAng) = tsolDiff * ShadeReflFac * ShadeTransSky
Construct(ConstrNum)%BlTransDiffVis(ISlatAng) = tvisDiff * ShadeReflFacVis * ShadeTransVis
Construct(ConstrNum)%BlReflectSolDiffFront(ISlatAng) = Construct(ConstrNum)%ReflectSolDiffFront + &
(tsolDiff**2) * ShadeRefl * ShadeReflFac
Construct(ConstrNum)%BlReflectVisDiffFront(ISlatAng) = Construct(ConstrNum)%ReflectVisDiffFront + &
(tvisDiff**2) * ShadeReflVis * ShadeReflFacVis
! Back incident solar, diffuse, interior blind
DO IGlass = 1,NGlass
Construct(ConstrNum)%BlAbsDiffBack(IGlass,ISlatAng) = &
Construct(ConstrNum)%AbsDiffBack(IGlass) * ShadeTrans * ShadeReflFac
END DO
Construct(ConstrNum)%AbsDiffBackBlind(ISlatAng) = Blind(BlNum)%SolBackDiffAbs(ISlatAng) + &
ShadeTrans*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffBack*ShadeAbs
Construct(ConstrNum)%BlReflectSolDiffBack(ISlatAng) = Blind(BlNum)%SolBackDiffDiffRefl(ISlatAng) + &
(ShadeTrans**2) * Construct(ConstrNum)%ReflectSolDiffBack * ShadeReflFac
Construct(ConstrNum)%BlReflectVisDiffBack(ISlatAng) = Blind(BlNum)%VisBackDiffDiffRefl(ISlatAng) + &
(ShadeTransVis**2) * Construct(ConstrNum)%ReflectVisDiffBack * ShadeReflFacVis
END IF ! End of check if interior blind
! Front incident solar, diffuse, interior shade
IF(IntShade) THEN
DO IGlass = 1,NGlass
Construct(ConstrNum)%AbsDiff(IGlass) = Construct(ConstrNum)%AbsDiff(IGlass) + &
tsolDiff * ShadeRefl * ShadeReflFac * solabsDiff(IGlass)
END DO
Construct(ConstrNum)%AbsDiffShade = tsolDiff * ShadeReflFac * ShadeAbs
Construct(ConstrNum)%TransDiff = tsolDiff * ShadeReflFac * ShadeTrans
Construct(ConstrNum)%TransDiffVis = tvisDiff * ShadeReflFacVis * ShadeTransVis
Construct(ConstrNum)%ReflectSolDiffFront = Construct(ConstrNum)%ReflectSolDiffFront + &
(tsolDiff**2) * ShadeRefl * ShadeReflFac
Construct(ConstrNum)%ReflectVisDiffFront = Construct(ConstrNum)%ReflectVisDiffFront + &
(tvisDiff**2) * ShadeReflVis * ShadeReflFacVis
! Back incident solar, diffuse, interior shade
DO IGlass = 1,NGlass
Construct(ConstrNum)%AbsDiffBack(IGlass) = &
Construct(ConstrNum)%AbsDiffBack(IGlass) * ShadeTrans * ShadeReflFac
END DO
Construct(ConstrNum)%AbsDiffBackShade = ShadeAbs * &
(1 + ShadeTrans*ShadeReflFac*Construct(ConstrNum)%ReflectSolDiffBack)
Construct(ConstrNum)%ReflectSolDiffBack = ShadeRefl + (ShadeTrans**2) * &
Construct(ConstrNum)%ReflectSolDiffBack * ShadeReflFac
Construct(ConstrNum)%ReflectVisDiffBack = ShadeReflVis + (ShadeTransVis**2) * &
Construct(ConstrNum)%ReflectVisDiffBack * ShadeReflFacVis
END IF ! End of check if interior shade
END IF ! End check if interior shade or blind
IF(BGShade.OR.BGBlind) THEN ! Between-glass shade/blind; assumed to be between glass #2 and glass #3
tsh2 = tsh**2
tshv2 = tshv**2
td1 = Construct(ConstrNum)%tBareSolDiff(1)
td2 = Construct(ConstrNum)%tBareSolDiff(2)
td1v = Construct(ConstrNum)%tBareVisDiff(1)
td2v = Construct(ConstrNum)%tBareVisDiff(2)
afd1 = Construct(ConstrNum)%afBareSolDiff(1)
afd2 = Construct(ConstrNum)%afBareSolDiff(2)
abd1 = Construct(ConstrNum)%abBareSolDiff(1)
abd2 = Construct(ConstrNum)%abBareSolDiff(2)
rb1 = Construct(ConstrNum)%rbBareSolDiff(1)
rb2 = Construct(ConstrNum)%rbBareSolDiff(2)
rb1v = Construct(ConstrNum)%rbBareVisDiff(1)
rb2v = Construct(ConstrNum)%rbBareVisDiff(2)
rf1 = Construct(ConstrNum)%rfBareSolDiff(1)
rf2 = Construct(ConstrNum)%rfBareSolDiff(2)
rf1v = Construct(ConstrNum)%rfBareVisDiff(1)
rf2v = Construct(ConstrNum)%rfBareVisDiff(2)
IF(BGShade) THEN
IF(NGlass==2) THEN
! Front incident solar, beam, between-glass shade, NGlass = 2
DO IPhi = 1,10
t1 = tBareSolPhi(IPhi,1)
t1v = tBareVisPhi(IPhi,1)
af1 = afBareSolPhi(IPhi,1)
ab1 = abBareSolPhi(IPhi,1)
tsolPhi(IPhi) = t1*(tsh + rsh*rb1*tsh + tsh*rf2*rsh)*td2
tvisPhi(IPhi) = t1v*(tshv + rshv*rb1v*tshv + tshv*rf2v*rshv)*td2v
solabsShadePhi(IPhi) = t1*(ash + rsh*rb1 + tsh*rf2)*ash
solabsPhi(IPhi,1) = af1 + t1*(rsh + rsh*rb1*rsh + tsh*rf2*tsh)*abd1
solabsPhi(IPhi,2) = t1*(tsh + rsh*rb1*tsh + tsh*rf2*rsh)*afd2
END DO ! End of loop over incidence angles
! Front incident solar, diffuse, between-glass shade, NGlass = 2
Construct(ConstrNum)%TransDiff = td1*(tsh + rsh*rb1*tsh + tsh*rb2*rsh)*td2
Construct(ConstrNum)%TransDiffVis = td1v*(tshv + rshv*rb1v*tshv + tshv*rb2v*rshv)*td2v
Construct(ConstrNum)%AbsDiffShade = td1*(ash + rsh*rb1*ash + tsh*rf2*ash)
Construct(ConstrNum)%AbsDiff(1) = afd1 + td1*(rsh + tsh*rb2*tsh)*abd1
Construct(ConstrNum)%AbsDiff(2) = td1*(tsh + rsh*rb1*tsh + tsh*rf2*rsh)*afd2
Construct(ConstrNum)%ReflectSolDiffFront = rf1 + td1*(rsh + rsh*rb1*rsh + tsh*rf2*tsh)*td1
Construct(ConstrNum)%ReflectVisDiffFront = rf1v + td1v*(rshv + rshv*rb1v*rshv + tshv*rf2v*tshv)*td1v
! Back incident solar, diffuse, between-glass shade, NGlass = 2
Construct(ConstrNum)%AbsDiffBackShade = td2*(ash + rsh*rf2*ash + tsh*rb1*ash)
Construct(ConstrNum)%AbsDiffBack(1) = td2*(tsh + rsh*rf2*tsh + tsh*rb1*rsh)*abd1
Construct(ConstrNum)%AbsDiffBack(2) = abd2 + td2*(rsh + rsh*rf2*rsh + tsh*rb1*tsh)*afd2
Construct(ConstrNum)%ReflectSolDiffBack = rb2 + td2*(rsh + rsh*rf2*rsh + tsh*rb1*tsh)*td2
Construct(ConstrNum)%ReflectVisDiffBack = rb2v + td2v*(rshv + rshv*rf2v*rshv + tshv*rb1v*tshv)*td2v
END IF ! End of check if NGlass = 2
IF(NGlass==3) THEN
td3 = Construct(ConstrNum)%tBareSolDiff(3)
td3v = Construct(ConstrNum)%tBareVisDiff(3)
afd3 = Construct(ConstrNum)%afBareSolDiff(3)
abd3 = Construct(ConstrNum)%abBareSolDiff(3)
rb3 = Construct(ConstrNum)%rbBareSolDiff(3)
rb3v = Construct(ConstrNum)%rbBareVisDiff(3)
rf3 = Construct(ConstrNum)%rfBareSolDiff(3)
rf3v = Construct(ConstrNum)%rfBareVisDiff(3)
! Front incident solar, beam, between-glass shade, NGlass = 3
DO IPhi = 1,10
t1 = tBareSolPhi(IPhi,1)
t1v = tBareVisPhi(IPhi,1)
t2 = tBareSolPhi(IPhi,2)
t2v = tBareVisPhi(IPhi,2)
af1 = afBareSolPhi(IPhi,1)
af2 = afBareSolPhi(IPhi,2)
ab1 = abBareSolPhi(IPhi,1)
ab2 = abBareSolPhi(IPhi,2)
rbmf2 = MAX(0.0d0,1.d0-(t2+af2))
tsolPhi(IPhi) = t1*t2*(tsh + tsh*rf3*rsh + rsh*td2*rb1*td2*tsh + rsh*rb2*tsh)*td3
tvisPhi(IPhi) = t1v*t2v*(tshv + tshv*rf3v*rshv + rshv*td2v*rb1v*td2v*tshv + rshv*rb2v*tshv)*td3v
solabsShadePhi(IPhi) = t1*t2*(1 + rsh*td2*rb1*td2 + rsh*rb2)*ash
solabsPhi(IPhi,1) = af1 + rbmf2*ab1 + &
t1*t2*rsh*(1 + rf3*tsh + rb2*rsh + td2*rb1*td2*rsh)*td2*abd1
solabsPhi(IPhi,2) = t1*af2 + t1*t2*((rsh + tsh*rf3*tsh + rsh*rb2*rsh)*abd2 + rsh*td2*rb1*afd2)
solabsPhi(IPhi,3) = t1*t2*(tsh + rsh*(rb2*tsh + td2*rb2*td2*tsh + rf3*rsh))*afd3
END DO ! End of loop over incidence angle
! Front incident solar, diffuse, between-glass shade, NGlass = 3
Construct(ConstrNum)%TransDiff = td1*td2*(tsh + rsh*td2*rb1*td2*tsh + rsh*rb2*tsh + tsh*rf3*rsh)*td3
Construct(ConstrNum)%TransDiffVis = &
td1v*td2v*(tshv + rshv*td2v*rb1v*td2v*tshv + rshv*rb2v*tshv + tshv*rf3v*rshv)*td3v
Construct(ConstrNum)%AbsDiffShade = td1*td2*(ash*(1 + rsh*td2*rb1*td2 + rsh*rb2*ash) + tsh*rf3*ash)
Construct(ConstrNum)%AbsDiff(1) = &
afd1 + td1*(rf2 + td2*(rsh + rsh*rb2*rsh + tsh*rf3*tsh + rsh*td2*rb1*td2*rsh)*td2)*abd1
Construct(ConstrNum)%AbsDiff(2) = td1*(afd2 + td2*(rsh + rsh*rb2*rsh + tsh*rf3*tsh)*abd2)
Construct(ConstrNum)%AbsDiff(3) = td1*td2*(tsh + rsh*rb2*tsh + rsh*td2*rb1*td2*tsh + tsh*rf3*rsh)*afd3
Construct(ConstrNum)%ReflectSolDiffFront = &
rf1 + td1*rf2*td1 + td1*td2*(rsh + tsh*rf3*tsh + rsh*rb2*rsh + rsh*td2*rb1*td2*rsh)*td2*td1
Construct(ConstrNum)%ReflectVisDiffFront = &
rf1v + td1v*rf2v*td1v + td1v*td2v*(rshv + tshv*rf3v*tshv + rshv*rb2v*rshv + &
rshv*td2v*rb1v*td2v*rshv)*td2v*td1v
! Back incident solar, diffuse, between-glass shade, NGlass = 3
Construct(ConstrNum)%AbsDiffBackShade = td3*((1 + rsh*rf3)*ash + (tsh*td2*rb1*td2 + tsh*rb2)*ash)
Construct(ConstrNum)%AbsDiffBack(1) = td3*(tsh + rsh*rf3*tsh + tsh*rb2*rsh + tsh*td2*rb1*td2*rsh)*td2*abd1
Construct(ConstrNum)%AbsDiffBack(2) = td3*((tsh + rsh*rf3*tsh)*abd2 + (tsh*td2*rb1*td2 + tsh*rb2)*afd2)
Construct(ConstrNum)%AbsDiffBack(3) = abd3 + td3*(rsh + tsh*rb2*tsh + tsh*td2*rb1*td2*tsh)*afd3
Construct(ConstrNum)%ReflectSolDiffBack = rb3 + td3*(rsh + rsh*rf3*rsh + tsh*rb2*tsh + tsh*td2*rb1*td2*tsh)*td3
Construct(ConstrNum)%ReflectVisDiffBack = &
rb3v + td3v*(rshv + rshv*rf3*rshv + tshv*rb2v*tshv + tshv*td2v*rb1v*td2v*tshv)*td3v
END IF ! End of check if NGlass = 3
END IF ! End of check if between-glass shade
IF(BGBlind) THEN
IF(NGlass==2) THEN
! Front incident solar, diffuse, between-glass blind, NGlass = 2
Construct(ConstrNum)%BlAbsDiff(1,ISlatAng) = afd1 + td1*(rfsh + rfsh*rb1*rfsh + tsh*rb2*tsh)*abd1
Construct(ConstrNum)%BlAbsDiffGnd(1,ISlatAng) = afd1 + td1*(rfshGnd + rfshGnd*rb1*rfshGnd + tshGnd*rb2*tsh)*abd1
Construct(ConstrNum)%BlAbsDiffSky(1,ISlatAng) = afd1 + td1*(rfshSky + rfshSky*rb1*rfshSky + tshSky*rb2*tsh)*abd1
Construct(ConstrNum)%BlAbsDiff(2,ISlatAng) = td1*(tsh + rfsh*rb1*tsh + tsh*rf2*rbsh)*afd2
Construct(ConstrNum)%BlAbsDiffGnd(2,ISlatAng) = td1*(tshGnd + rfshGnd*rb1*tsh + tshGnd*rf2*rbsh)*afd2
Construct(ConstrNum)%BlAbsDiffSky(2,ISlatAng) = td1*(tshSky + rfshSky*rb1*tsh + tshSky*rf2*rbsh)*afd2
Construct(ConstrNum)%AbsDiffBlind(ISlatAng) = td1*(afsh + rfsh*rb1*afsh + tsh*rf2*absh)
Construct(ConstrNum)%AbsDiffBlindGnd(ISlatAng)= td1*(afshGnd + rfsh*rb1*afsh + tshGnd*rf2*absh)
Construct(ConstrNum)%AbsDiffBlindSky(ISlatAng)= td1*(afshSky + rfsh*rb1*afsh + tshSky*rf2*absh)
Construct(ConstrNum)%BlTransDiff(ISlatAng) = td1*(tsh + rfsh*rb1*tsh + tsh*rb2*rbsh)*td2
Construct(ConstrNum)%BlTransDiffGnd(ISlatAng) = td1*(tshGnd + rfsh*rb1*tshGnd + tshGnd*rb2*rbsh)*td2
Construct(ConstrNum)%BlTransDiffSky(ISlatAng) = td1*(tshSky + rfsh*rb1*tshSky + tshSky*rb2*rbsh)*td2
Construct(ConstrNum)%BlTransDiffVis(ISlatAng) = td1v*(tshv + rfshv*rb1v*tshv + tshv*rb2v*rbshv)*td2v
Construct(ConstrNum)%BlReflectSolDiffFront(ISlatAng) = rf1 + td1*(rfsh + rfsh*rb1*rfsh + tsh*rf2*tsh)*td1
Construct(ConstrNum)%BlReflectVisDiffFront(ISlatAng) = &
rf1v + td1v*(rfshv + rfshv*rb1v*rfshv + tshv*rf2v*tshv)*td1v
! Back incident solar, diffuse, between-glass blind, NGlass = 2
Construct(ConstrNum)%BlAbsDiffBack(1,ISlatAng) = td2*(tsh + rbsh*rf2*tsh + tsh*rb1*rfsh)*abd1
Construct(ConstrNum)%BlAbsDiffBack(2,ISlatAng) = abd2 + td2*(rbsh + rbsh*rf2*rbsh + tsh*rb1*tsh)*afd2
Construct(ConstrNum)%AbsDiffBackBlind(ISlatAng) = td2*(absh + rbsh*rf2*absh + tsh*rb1*afsh)
Construct(ConstrNum)%BlReflectSolDiffBack(ISlatAng) = rb2 + td2*(rbsh + rbsh*rf2*rbsh + tsh*rb1*tsh)*td2
Construct(ConstrNum)%BlReflectVisDiffBack(ISlatAng) = &
rb2v + td2v*(rbshv + rbshv*rf2v*rbshv + tshv*rb1v*tshv)*td2v
END IF ! End of check if NGlass = 2
IF(NGlass==3) THEN
td3 = Construct(ConstrNum)%tBareSolDiff(3)
td3v = Construct(ConstrNum)%tBareVisDiff(3)
afd3 = Construct(ConstrNum)%afBareSolDiff(3)
abd3 = Construct(ConstrNum)%abBareSolDiff(3)
rb3 = Construct(ConstrNum)%rbBareSolDiff(3)
rb3v = Construct(ConstrNum)%rbBareVisDiff(3)
rf3 = Construct(ConstrNum)%rfBareSolDiff(3)
rf3v = Construct(ConstrNum)%rfBareVisDiff(3)
! Front incident solar, diffuse, between-glass blind, NGlass = 3
Construct(ConstrNum)%BlAbsDiff(1,ISlatAng) = &
afd1 + td1*(rf2 + td2*(rfsh + rfsh*rb2*rfsh + tsh*rf3*tsh + rfsh*td2*rb1*td2*rfsh)*td2)*abd1
Construct(ConstrNum)%BlAbsDiffGnd(1,ISlatAng) = &
afd1 + td1*(rf2 + td2*(rfshGnd + rfshGnd*rb2*rfsh + tshGnd*rf3*tsh + rfshGnd*td2*rb1*td2*rfsh)*td2)*abd1
Construct(ConstrNum)%BlAbsDiffSky(1,ISlatAng) = &
afd1 + td1*(rf2 + td2*(rfshSky + rfshSky*rb2*rfsh + tshSky*rf3*tsh + rfshSky*td2*rb1*td2*rfsh)*td2)*abd1
Construct(ConstrNum)%BlAbsDiff(2,ISlatAng) = &
td1*(afd2 + td2*(rfsh + rfsh*rb2*rfsh + tsh*rf3*tsh)*abd2)
Construct(ConstrNum)%BlAbsDiffGnd(2,ISlatAng) = &
td1*(afd2 + td2*(rfshGnd + rfshGnd*rb2*rfsh + tshGnd*rf3*tsh)*abd2)
Construct(ConstrNum)%BlAbsDiffSky(2,ISlatAng) = &
td1*(afd2 + td2*(rfshSky + rfshSky*rb2*rfsh + tshSky*rf3*tsh)*abd2)
Construct(ConstrNum)%BlAbsDiff(3,ISlatAng) = &
td1*td2*(tsh + rfsh*rb2*tsh + rfsh*td2*rb1*td2*tsh + tsh*rf3*rbsh)*afd3
Construct(ConstrNum)%BlAbsDiffGnd(3,ISlatAng) = &
td1*td2*(tshGnd + rfshGnd*rb2*tsh + rfshGnd*td2*rb1*td2*tsh + tshGnd*rf3*rbsh)*afd3
Construct(ConstrNum)%BlAbsDiffSky(3,ISlatAng) = &
td1*td2*(tshSky + rfshSky*rb2*tsh + rfshSky*td2*rb1*td2*tsh + tshSky*rf3*rbsh)*afd3
Construct(ConstrNum)%AbsDiffBlind(ISlatAng) = &
td1*td2*(afsh*(1 + rfsh*td2*rb1*td2) + rfsh*rb2*afsh + tsh*rf3*absh)
Construct(ConstrNum)%AbsDiffBlindGnd(ISlatAng) = &
td1*td2*(afshGnd + afsh*rfsh*(td2*rb1*td2 + rb2) + tshGnd*rf3*absh)
Construct(ConstrNum)%AbsDiffBlindSky(ISlatAng) = &
td1*td2*(afshSky + afsh*rfsh*(td2*rb1*td2 + rb2) + tshSky*rf3*absh)
Construct(ConstrNum)%BlTransDiff(ISlatAng) = &
td1*td2*(tsh + rfsh*td2*rb1*td2*tsh + rfsh*rb2*tsh + tsh*rf3*rbsh)*td3
Construct(ConstrNum)%BlTransDiffGnd(ISlatAng) = &
td1*td2*(tshGnd + rfsh*td2*rb1*td2*tshGnd + rfsh*rb2*tshGnd + tshGnd*rf3*rbsh)*td3
Construct(ConstrNum)%BlTransDiffSky(ISlatAng) = &
td1*td2*(tshSky + rfsh*td2*rb1*td2*tshSky + rfsh*rb2*tshSky + tshSky*rf3*rbsh)*td3
Construct(ConstrNum)%BlTransDiffVis(ISlatAng) = &
td1v*td2v*(tshv + rfshv*td2v*rb1v*td2v*tshv + rfshv*rb2v*tshv + tshv*rf3v*rbshv)*td3v
Construct(ConstrNum)%BlReflectSolDiffFront(ISlatAng) = &
rf1 + td1*rf2*td1 + td1*td2*(rfsh + tsh*rf3*tsh + rfsh*rb2*rfsh + rfsh*td2*rb1*td2*rfsh)*td2*td1
Construct(ConstrNum)%BlReflectVisDiffFront(ISlatAng) = &
rf1v + td1v*rf2v*td1v + td1v*td2v*(rfshv + tshv*rf3v*tshv + rfshv*rb2v*rfshv + &
rfshv*td2v*rb1v*td2v*rfshv)*td2v*td1v
! Back incident solar, diffuse, between-glass blind, NGlass = 3
Construct(ConstrNum)%BlAbsDiffBack(1,ISlatAng) = &
td3*(tsh + rbsh*rf3*tsh + tsh*rb2*rfsh + tsh*td2*rb1*td2*rfsh)*td2*abd1
Construct(ConstrNum)%BlAbsDiffBack(2,ISlatAng) = &
td3*((tsh + rbsh*rf3*tsh)*abd2 + (tsh*td2*rb1*td2 + tsh*rb2)*afd2)
Construct(ConstrNum)%BlAbsDiffBack(3,ISlatAng) = &
abd3 + td3*(rbsh + tsh*rb2*tsh + tsh*td2*rb1*td2*tsh)*afd3
Construct(ConstrNum)%AbsDiffBackBlind(ISlatAng) = &
td3*((1 + rbsh*rf3)*absh + (tsh*td2*rb1*td2 + tsh*rb2)*afsh)
Construct(ConstrNum)%BlReflectSolDiffBack(ISlatAng) = &
rb3 + td3*(rbsh + rbsh*rf3*rbsh + tsh*rb2*tsh + tsh*td2*rb1*td2*tsh)*td3
Construct(ConstrNum)%BlReflectVisDiffBack(ISlatAng) = &
rb3v + td3v*(rbshv + rbshv*rf3v*rbshv + tshv*rb2v*tshv + tshv*td2v*rb1v*td2v*tshv)*td3v
END IF ! End of check if NGlass = 3
END IF ! End of check if between-glass blind
END IF ! End of check if between-glass shade or blind
! Continue loop over slat angles only for blinds with variable slat angle
IF(ShadeOn .OR. ScreenOn) EXIT
IF(BlindOn) THEN
IF(Blind(BlNum)%SlatAngleType == FixedSlats) EXIT
END IF
END DO ! End of slat angle loop
END IF ! End of check if construction has a shade or blind
! Curve fits to get solar transmittance, reflectance, layer absorptance and
! visible transmittance as polynomials in cosine of incidence angle
IF(.NOT. BlindOn .AND. .NOT. ScreenOn) THEN ! Bare glass or shade on
CALL W5LsqFit(CosPhiIndepVar,tsolPhi,6,1,10,Construct(ConstrNum)%TransSolBeamCoef(1:6))
CALL W5LsqFit(CosPhiIndepVar,rfsolPhi,6,1,10,Construct(ConstrNum)%ReflSolBeamFrontCoef(1:6))
CALL W5LsqFit(CosPhiIndepVar,rbsolPhi,6,1,10,Construct(ConstrNum)%ReflSolBeamBackCoef(1:6))
CALL W5LsqFit(CosPhiIndepVar,tvisPhi,6,1,10,Construct(ConstrNum)%TransVisBeamCoef)
DO IGlass = 1,NGlass
! Front absorptance coefficients for glass layers
DepVarCurveFit(1:10) = solabsPhi(1:10,IGlass)
CALL W5LsqFit(CosPhiIndepVar,DepVarCurveFit,6,1,10,CoeffsCurveFit)
Construct(ConstrNum)%AbsBeamCoef(IGlass,1:6) = CoeffsCurveFit
! Back absorptance coefficients for glass layers
IGlassBack = NGlass-IGlass+1
DepVarCurveFit(1:10) = solabsBackPhi(1:10,IGlassBack)
CALL W5LsqFit(CosPhiIndepVar,DepVarCurveFit,6,1,10,CoeffsCurveFit)
Construct(ConstrNum)%AbsBeamBackCoef(IGlass,1:6) = CoeffsCurveFit
END DO
! To check goodness of fit
DO IPhi = 1,10
tsolPhiFit(IPhi) = 0.d0
tvisPhiFit(IPhi) = 0.d0
Phi = REAL(IPhi-1,r64)*10.d0
CosPhi = COS(Phi*DegToRadians)
if (abs(CosPhi) < .0001d0) CosPhi=0.0d0
DO CoefNum = 1,6
tsolPhiFit(IPhi) = tsolPhiFit(IPhi) + Construct(ConstrNum)%TransSolBeamCoef(CoefNum)* &
CosPhi**CoefNum
tvisPhiFit(IPhi) = tvisPhiFit(IPhi) + Construct(ConstrNum)%TransVisBeamCoef(CoefNum)* &
CosPhi**CoefNum
END DO
END DO
END IF
IF(ShadeOn) CALL W5LsqFit(CosPhiIndepVar,solabsShadePhi,6,1,10,Construct(ConstrNum)%AbsBeamShadeCoef)
END DO ! End of loop over constructions
! Get effective glass and shade/blind emissivities for windows that have interior blind or
! shade. These are used to calculate zone MRT contribution from window when
! interior blind/shade is deployed.
DO SurfNum = 1,TotSurfaces
IF (.not. Surface(SurfNum)%HeatTransSurf) CYCLE
IF(.NOT.Construct(Surface(SurfNum)%Construction)%TypeIsWindow) CYCLE
IF( SurfaceWindow(SurfNum)%WindowModelType == WindowBSDFModel ) CYCLE !Irrelevant for Complex Fen
IF( Construct(Surface(SurfNum)%Construction)%WindowTypeEQL ) CYCLE ! not required
ConstrNumSh = SurfaceWindow(SurfNum)%ShadedConstruction
IF(ConstrNumSh == 0) CYCLE
TotLay = Construct(ConstrNumSh)%TotLayers
IntShade = .FALSE.
IntBlind = .FALSE.
IF(Material(Construct(ConstrNumSh)%LayerPoint(TotLay))%Group == Shade) THEN
IntShade = .TRUE.
ShadeLayPtr = Construct(ConstrNumSh)%LayerPoint(TotLay)
END IF
IF(Material(Construct(ConstrNumSh)%LayerPoint(TotLay))%Group == WindowBlind) THEN
IntBlind = .TRUE.
BlNum = Material(Construct(ConstrNumSh)%LayerPoint(TotLay))%BlindDataPtr
END IF
IF(IntShade.OR.IntBlind) THEN
DO ISlatAng = 1,MaxSlatAngs
IF(IntShade.OR.IntBlind) THEN
EpsGlIR = Material(Construct(ConstrNumSh)%LayerPoint(TotLay-1))%AbsorpThermalBack
RhoGlIR = 1-EpsGlIR
END IF
IF(IntShade) THEN
TauShIR = Material(ShadeLayPtr)%TransThermal
EpsShIR = Material(ShadeLayPtr)%AbsorpThermal
RhoShIR = MAX(0.d0,1.d0-TauShIR-EpsShIR)
SurfaceWindow(SurfNum)%EffShBlindEmiss(1) = EpsShIR*(1.d0+RhoGlIR*TauShIR/(1.d0-RhoGlIR*RhoShIR))
SurfaceWindow(SurfNum)%EffGlassEmiss(1) = EpsGlIR*TauShIR/(1.d0-RhoGlIR*RhoShIR)
END IF
IF(IntBlind) THEN
TauShIR = Blind(BlNum)%IRFrontTrans(ISlatAng)
EpsShIR = Blind(BlNum)%IRBackEmiss(ISlatAng)
RhoShIR = MAX(0.d0,1.d0-TauShIR-EpsShIR)
SurfaceWindow(SurfNum)%EffShBlindEmiss(ISlatAng) = EpsShIR*(1.d0+RhoGlIR*TauShIR/(1.d0-RhoGlIR*RhoShIR))
SurfaceWindow(SurfNum)%EffGlassEmiss(ISlatAng) = EpsGlIR*TauShIR/(1.d0-RhoGlIR*RhoShIR)
END IF
! Loop over remaining slat angles only if blind with movable slats
IF(IntShade) EXIT ! Loop over remaining slat angles only if blind
IF(IntBlind) THEN
IF(Blind(BlNum)%SlatAngleType == FixedSlats) EXIT
END IF
END DO ! End of slat angle loop
END IF ! End of check if interior shade or interior blind
END DO ! End of surface loop
DO SurfNum = 1,TotSurfaces
IF(Surface(SurfNum)%Construction <= 0) CYCLE
IF(.NOT.Construct(Surface(SurfNum)%Construction)%TypeIsWindow) CYCLE
ConstrNum = Surface(SurfNum)%Construction
! Total thickness of glazing system (used in calculation of inside reveal reflection/absorption
SurfaceWindow(SurfNum)%TotGlazingThickness = 0.0d0
DO LayNum = 1,Construct(ConstrNum)%TotLayers
SurfaceWindow(SurfNum)%TotGlazingThickness = SurfaceWindow(SurfNum)%TotGlazingThickness + &
Material(Construct(ConstrNum)%LayerPoint(LayNum))%Thickness
END DO
! Sine and cosine of azimuth and tilt
! SurfaceWindow(SurfNum)%SinAzim = Surface(SurfNum)%SinAzim
! SurfaceWindow(SurfNum)%CosAzim = Surface(SurfNum)%CosAzim
! SurfaceWindow(SurfNum)%SinTilt = Surface(SurfNum)%SinTilt
! SurfaceWindow(SurfNum)%CosTilt = Surface(SurfNum)%CosTilt
! ! Outward normal unit vector (pointing away from room)
! SurfaceWindow(SurfNum)%OutNormVec(1) = Surface(SurfNum)%OutNormVec(1)
! SurfaceWindow(SurfNum)%OutNormVec(2) = Surface(SurfNum)%OutNormVec(2)
! SurfaceWindow(SurfNum)%OutNormVec(3) = Surface(SurfNum)%OutNormVec(3)
! write(outputfiledebug,*) 'window='//trim(surface(surfnum)%name)
! write(outputfiledebug,*) ' swindow%outnormvec=',surfacewindow(surfnum)%outnormvec
! write(outputfiledebug,*) ' surface%outnormvec=',surface(surfnum)%outnormvec
! Window center
Rectangle = .FALSE.
Triangle = .FALSE.
IF(Surface(SurfNum)%Sides == 3) Triangle = .TRUE.
IF(Surface(SurfNum)%Sides == 4) Rectangle = .TRUE.
IF(Rectangle) THEN
! Vertices of window (numbered counter-clockwise starting at upper left as viewed from inside of room).
! Assumes original vertices are numbered counter-clockwise from upper left as viewed from outside.
W3 = Surface(SurfNum)%Vertex(2)
W2 = Surface(SurfNum)%Vertex(3)
W1 = Surface(SurfNum)%Vertex(4)
ELSE IF (Triangle) THEN
W3 = Surface(SurfNum)%Vertex(2)
W2 = Surface(SurfNum)%Vertex(3)
W1 = Surface(SurfNum)%Vertex(1)
END IF
W21 = W1 - W2
W23 = W3 - W2
IF(Rectangle) THEN
SurfaceWindow(SurfNum)%WinCenter = W2 + (W23 + W21) / 2.0d0
ELSE IF(Triangle) THEN
SurfaceWindow(SurfNum)%WinCenter = W2 + (W23 + W21) / 3.0d0
END IF
END DO ! End of surface loop
CALL ReportGlass
RETURN
END SUBROUTINE InitGlassOpticalCalculations