! function attributes:
! INPUTS:
! General:
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nlayer | |||
integer, | intent(in) | :: | iwd | |||
real(kind=r64), | intent(inout) | :: | tout | |||
real(kind=r64), | intent(inout) | :: | tind | |||
real(kind=r64), | intent(inout) | :: | trmin | |||
real(kind=r64), | intent(in) | :: | wso | |||
real(kind=r64), | intent(in) | :: | wsi | |||
real(kind=r64), | intent(in) | :: | dir | |||
real(kind=r64), | intent(in) | :: | outir | |||
integer, | intent(in) | :: | isky | |||
real(kind=r64), | intent(in) | :: | tsky | |||
real(kind=r64), | intent(inout) | :: | esky | |||
real(kind=r64), | intent(in) | :: | fclr | |||
real(kind=r64), | intent(in) | :: | VacuumPressure | |||
real(kind=r64), | intent(in) | :: | VacuumMaxGapThickness | |||
real(kind=r64), | intent(inout), | dimension(MaxGap) | :: | gap | ||
real(kind=r64), | intent(inout), | dimension(maxlay) | :: | thick | ||
real(kind=r64), | intent(inout), | dimension(maxlay) | :: | scon | ||
real(kind=r64), | intent(in), | dimension(maxlay2) | :: | tir | ||
real(kind=r64), | intent(in), | dimension(maxlay2) | :: | emis | ||
real(kind=r64), | intent(in) | :: | totsol | |||
real(kind=r64), | intent(in) | :: | tilt | |||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | asol | ! Venetians: |
|
real(kind=r64), | intent(in) | :: | height | |||
real(kind=r64), | intent(in) | :: | heightt | |||
real(kind=r64), | intent(in) | :: | width | |||
real(kind=r64), | intent(in), | dimension(maxlay1) | :: | presure | ||
integer, | intent(in), | dimension(maxlay1, maxgas) | :: | iprop | ||
real(kind=r64), | intent(in), | dimension(maxlay1, maxgas) | :: | frct | ||
real(kind=r64), | intent(in), | dimension(maxgas,3) | :: | xgcon | ||
real(kind=r64), | intent(in), | dimension(maxgas,3) | :: | xgvis | ||
real(kind=r64), | intent(in), | dimension(maxgas,3) | :: | xgcp | ||
real(kind=r64), | intent(in), | dimension(maxgas) | :: | xwght | ||
real(kind=r64), | intent(in), | dimension(maxgas) | :: | gama | ||
integer, | intent(in), | dimension(maxlay1) | :: | nmix | ||
integer, | intent(in), | dimension(maxlay) | :: | SupportPillar | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | PillarSpacing | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | PillarRadius | ||
real(kind=r64), | intent(inout), | dimension(maxlay2) | :: | theta | ||
real(kind=r64), | intent(out), | dimension(maxlay3) | :: | q | ||
real(kind=r64), | intent(out), | dimension(maxlay1) | :: | qv | ||
real(kind=r64), | intent(out) | :: | ufactor | |||
real(kind=r64), | intent(out) | :: | sc | |||
real(kind=r64), | intent(out) | :: | hflux | |||
real(kind=r64), | intent(out) | :: | hcin | ! Layers: |
||
real(kind=r64), | intent(out) | :: | hcout | ! Layers: |
||
real(kind=r64), | intent(out) | :: | hrin | ! Layers: |
||
real(kind=r64), | intent(out) | :: | hrout | ! Layers: |
||
real(kind=r64), | intent(inout) | :: | hin | ! OUTPUTS: ! Overall: |
||
real(kind=r64), | intent(inout) | :: | hout | ! OUTPUTS: ! Overall: |
||
real(kind=r64), | intent(out), | dimension(maxlay1) | :: | hcgas | ||
real(kind=r64), | intent(out), | dimension(maxlay1) | :: | hrgas | ||
real(kind=r64), | intent(out) | :: | shgc | |||
integer, | intent(out) | :: | nperr | |||
character(len=*), | intent(inout) | :: | ErrorMessage | |||
real(kind=r64), | intent(out) | :: | shgct | |||
real(kind=r64), | intent(out) | :: | tamb | ! Layers: |
||
real(kind=r64), | intent(out) | :: | troom | ! Layers: |
||
integer, | intent(in), | dimension(2) | :: | ibc | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | Atop | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | Abot | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | Al | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | Ar | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | Ah | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatThick | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatWidth | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatAngle | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatCond | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatSpacing | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | SlatCurve | ||
real(kind=r64), | intent(in), | dimension(maxlay1) | :: | vvent | ! Laminates: |
|
real(kind=r64), | intent(in), | dimension(maxlay1) | :: | tvent | ! Laminates: |
|
integer, | intent(in), | dimension(maxlay) | :: | LayerType | ||
integer, | intent(in), | dimension(maxlay) | :: | nslice | ||
real(kind=r64), | intent(in), | dimension(maxlay) | :: | LaminateA(maxlay) | ! Gaps: |
|
real(kind=r64), | intent(in), | dimension(maxlay) | :: | LaminateB(maxlay) | ! Gaps: |
|
real(kind=r64), | intent(in), | dimension(maxlay) | :: | sumsol(maxlay) | ! Gaps: |
|
real(kind=r64), | intent(out), | dimension(maxlay) | :: | Ra | ! Shading related: |
|
real(kind=r64), | intent(out), | dimension(maxlay) | :: | Nu | ! Shading related: |
|
integer, | intent(in) | :: | ThermalMod | |||
integer, | intent(in) | :: | Debug_mode | ! Environment related: |
||
real(kind=r64), | intent(out) | :: | ShadeEmisRatioOut | |||
real(kind=r64), | intent(out) | :: | ShadeEmisRatioIn | |||
real(kind=r64), | intent(out) | :: | ShadeHcRatioOut | |||
real(kind=r64), | intent(out) | :: | ShadeHcRatioIn | |||
real(kind=r64), | intent(out) | :: | HcUnshadedOut | |||
real(kind=r64), | intent(out) | :: | HcUnshadedin | |||
real(kind=r64), | intent(out), | dimension(maxlay) | :: | Keff | ! Gaps: |
|
real(kind=r64), | intent(out), | dimension(MaxGap) | :: | ShadeGapKeffConv | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
real(kind=r64), | intent(in) | :: | SDScalar | !! INPUTS/OUTPUTS: |
||
integer, | intent(in) | :: | SHGCCalc | |||
integer, | intent(out) | :: | NumOfIterations | ! Layers: |
subroutine Calc_ISO15099(nlayer,iwd,tout,tind,trmin,wso,wsi,dir,outir,isky,tsky,esky,fclr,VacuumPressure,VacuumMaxGapThickness, &
& gap,thick,scon,tir,emis,totsol, &
& tilt,asol,height,heightt,width,presure,iprop,frct,xgcon,xgvis,xgcp,xwght,gama,nmix, &
& SupportPillar, PillarSpacing, PillarRadius, &
& theta,q,qv,ufactor,sc,hflux,hcin,hcout,hrin,hrout,hin,hout,hcgas,hrgas,shgc,nperr,ErrorMessage, &
& shgct,tamb,troom,ibc,Atop,Abot,Al,Ar,Ah, SlatThick, SlatWidth, SlatAngle, &
& SlatCond, SlatSpacing, SlatCurve, vvent,tvent, LayerType, nslice, LaminateA, LaminateB, &
& sumsol, Ra,Nu, ThermalMod, Debug_mode, &
& ShadeEmisRatioOut, ShadeEmisRatioIn, ShadeHcRatioOut, ShadeHcRatioIn, &
& HcUnshadedOut, HcUnshadedIn, Keff, ShadeGapKeffConv, SDScalar, SHGCCalc, NumOfIterations)
!!! function attributes:
!!! INPUTS:
!!! General:
integer, intent(in) :: nlayer
real(r64), intent(in) :: width, height, heightt
integer, intent(in) :: ThermalMod
integer, intent(in) :: SHGCCalc ! SHGC calculation switch:
! 0 - do not perform SHGC calculations
! 1 - perform SHGC calculations
integer, intent(in) :: Debug_mode ! Switch for debug output files:
! 0 - don't create debug output files
! 1 - append results to existing debug output file
! 2 - store results in new debug output file
! 3 - save in-between results (in all iterations) to existing debug file
!!! Environment related:
real(r64), intent(in) :: wso, wsi, dir, outir, tsky, fclr, VacuumPressure, VacuumMaxGapThickness, totsol, tilt
real(r64), intent(inout) :: tout, tind
integer, intent(in) :: iwd, isky
integer, dimension(2), intent(in) :: ibc
integer, intent(out) :: NumOfIterations
!!! Layers:
integer, dimension(maxlay), intent(in) :: LayerType
real(r64), dimension(maxlay2), intent(in) :: tir, emis
real(r64), dimension(maxlay), intent(in) :: asol
!!! Venetians:
real(r64), dimension(maxlay), intent(in) :: Atop, Abot, Al, Ar, Ah
real(r64), dimension(maxlay), intent(in) :: SlatThick, SlatWidth, SlatAngle
real(r64), dimension(maxlay), intent(in) :: SlatCond, SlatSpacing, SlatCurve
real(r64), dimension(maxlay1), intent(in) :: vvent, tvent
!!! Laminates:
integer, dimension(maxlay), intent(in) :: nslice
real(r64), dimension(maxlay), intent(in) :: LaminateA(maxlay), LaminateB(maxlay), sumsol(maxlay)
!!! Gaps:
integer, dimension(maxlay1, maxgas), intent(in) :: iprop
integer, dimension(maxlay1), intent(in) :: nmix
real(r64), dimension(maxlay1, maxgas), intent(in) :: frct
real(r64), dimension(maxlay1), intent(in) :: presure
real(r64), dimension(maxgas,3), intent(in) :: xgcon, xgvis, xgcp
real(r64), dimension(maxgas), intent(in) :: xwght, gama
integer, dimension(maxlay), intent(in) :: SupportPillar ! Shows whether or not gap have support pillar
! 0 - does not have support pillar
! 1 - have support pillar
real(r64), dimension(maxlay), intent(in) :: PillarSpacing ! Pillar spacing for each gap (used in case there is support pillar)
real(r64), dimension(maxlay), intent(in) :: PillarRadius ! Pillar radius for each gap (used in case there is support pillar)
real(r64), intent(in) :: SDScalar
!!!! INPUTS/OUTPUTS:
real(r64), intent(inout) :: esky, trmin
real(r64), dimension(maxlay), intent(inout) :: scon, thick
real(r64), dimension(MaxGap), intent(inout) :: gap
real(r64), intent(inout) :: hin, hout
!!! OUTPUTS:
!!! Overall:
integer, intent(out) :: nperr
character(len=*), intent(inout) :: ErrorMessage
real(r64), intent(out) :: ufactor, sc, hflux
real(r64), intent(out) :: shgc, shgct
real(r64), intent(out) :: hcin, hrin, hcout, hrout, tamb, troom
!!! Layers:
real(r64), dimension(maxlay2), intent(inout) :: theta
real(r64), dimension(maxlay3), intent(out) :: q
real(r64), dimension(maxlay1), intent(out) :: qv
real(r64), dimension(maxlay), intent(out) :: Keff
!!! Gaps:
real(r64), dimension(maxlay1), intent(out) :: hcgas, hrgas
real(r64), dimension(maxlay), intent(out) :: Ra, Nu
!!! Shading related:
real(r64), intent(out) :: ShadeEmisRatioOut, ShadeEmisRatioIn, ShadeHcRatioOut, ShadeHcRatioIn
real(r64), intent(out) :: HcUnshadedOut, HcUnshadedin
real(r64), dimension(MaxGap), intent(out) :: ShadeGapKeffConv
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Variables
real(r64), dimension(maxlay2) :: thetas, rir
real(r64), dimension(maxlay1) :: hcgass, hrgass
real(r64), dimension(maxlay3) :: rs=0.0d0
! real(r64) :: grho(maxgas,3)
real(r64), dimension(maxlay3) :: qs
real(r64), dimension(maxlay1) :: qvs
real(r64), dimension(maxlay) :: LaminateAU, sumsolU, sol0
real(r64) :: shgct_NOSD,trmout
real(r64) :: Gout, Gin, AchievedErrorTolerance, AchievedErrorToleranceSolar
integer :: NumOfIter, NumOfIterSolar
real(r64) :: tgg, qc1, qc2, qcgg
real(r64), dimension(maxlay1) :: qcgas, qcgaps, qrgas, qrgaps
real(r64) :: ShadeHcModifiedOut, ShadeHcModifiedIn
!real(r64) :: xgrho(maxgas, 3) !!!!!!!!!!!!!!!!!1
!cbi...Variables for "unshaded" run:
logical :: NeedUnshadedRun
integer :: nlayer_NOSD
real(r64) :: AchievedErrorTolerance_NOSD
integer :: NumOfIter_NOSD
real(r64), dimension(maxlay) :: Atop_NOSD, Abot_NOSD, Al_NOSD, Ar_NOSD, Ah_NOSD
real(r64), dimension(maxlay) :: SlatThick_NOSD, SlatWidth_NOSD, SlatAngle_NOSD
real(r64), dimension(maxlay) :: SlatCond_NOSD, SlatSpacing_NOSD, SlatCurve_NOSD
real(r64), dimension(maxlay1) :: vvent_NOSD, tvent_NOSD, qv_NOSD
real(r64), dimension(maxlay3) :: q_NOSD
real(r64) :: hin_NOSD, flux_NOSD, hcin_NOSD, hrin_NOSD, hcout_NOSD, hrout_NOSD
real(r64) :: tamb_NOSD, troom_NOSD
integer, dimension(maxlay) :: LayerType_NOSD
real(r64) :: ufactor_NOSD,sc_NOSD,hflux_NOSD,shgc_NOSD,hout_NOSD
real(r64), dimension(maxlay) :: gap_NOSD, thick_NOSD, scon_NOSD
real(r64), dimension(maxlay2) :: emis_NOSD, rir_NOSD, tir_NOSD
real(r64), dimension(maxlay2) :: theta_NOSD
real(r64), dimension(maxlay1, maxgas) :: frct_NOSD
integer, dimension(maxlay1, maxgas) :: iprop_NOSD
integer, dimension(maxlay1) :: nmix_NOSD
real(r64), dimension(maxlay1) :: presure_NOSD
real(r64), dimension(maxlay1) :: hcgas_NOSD, hrgas_NOSD
!real(r64) :: rs_NOSD(maxlay3)!,sol(maxlay)
real(r64), dimension(maxlay) :: LaminateA_NOSD, LaminateB_NOSD, sumsol_NOSD
real(r64), dimension(maxlay) :: Ra_NOSD, Nu_NOSD
real(r64) :: ShadeEmisRatioOut_NOSD, ShadeEmisRatioIn_NOSD
real(r64) :: ShadeHcRatioOut_NOSD, ShadeHcRatioIn_NOSD
real(r64) :: ShadeHcModifiedOut_NOSD, ShadeHcModifiedIn_NOSD
real(r64), dimension(maxlay) :: Ebb, Ebf, Rb, Rf
real(r64), dimension(maxlay) :: Ebbs, Ebfs, Rbs, Rfs
real(r64), dimension(maxlay) :: Ebb_NOSD, Ebf_NOSD, Rb_NOSD, Rf_NOSD
real(r64), dimension(MaxGap) :: ShadeGapKeffConv_NOSD
real(r64), dimension(maxlay1) :: qcgas_NOSD, Keff_NOSD, qrgas_NOSD
integer, dimension(maxlay) :: nslice_NOSD
real(r64), dimension(maxlay1) :: vfreevent_NOSD
integer :: FirstSpecularLayer, LastSpecularLayer
real(r64), dimension(maxlay1) :: vfreevent
!cbi...Other variables:
real(r64) :: flux, hint, houtt, Ebsky, Ebroom
integer :: i, j
integer :: OriginalIndex, UnshadedDebug
real(r64) :: rtot=0.0d0
real(r64) :: sft=0.0d0
real(r64) :: hcins=0.0d0
real(r64) :: hrins=0.0d0
real(r64) :: hins=0.0d0
real(r64) :: hcouts=0.0d0
real(r64) :: hrouts=0.0d0
real(r64) :: houts=0.0d0
real(r64) :: ufactors=0.0d0
real(r64) :: fluxs=0.0d0
real(r64) :: qeff=0.0d0
real(r64) :: flux_nonsolar=0.0d0
AchievedErrorTolerance = 0.0d0
AchievedErrorToleranceSolar = 0.0d0
AchievedErrorTolerance_NOSD = 0.0d0
call PrepVariablesISO15099(nlayer, tout, tind, trmin, isky, outir, tsky, esky, fclr, gap, thick, scon, tir, emis, &
& tilt, hin, hout, ibc, SlatThick, SlatWidth, SlatAngle, SlatCond, LayerType, &
& ThermalMod, SDScalar, ShadeEmisRatioOut, ShadeEmisRatioIn, ShadeHcRatioOut, ShadeHcRatioIn, &
& Keff, ShadeGapKeffConv, sc, shgc, ufactor, flux, LaminateAU, sumsolU, sol0, &
& hint, houtt, trmout, ebsky, ebroom, Gout, Gin, rir, vfreevent, nperr, ErrorMessage)
!No option to take hardcoded variables. All gas coefficients are now passed from outside.
!if (GoAhead(nperr)) call propcon90(ISO15099,mgas,xgcon,xgvis,xgcp,xgrho,xwght,nperr)
! exit on error
if (.not.(GoAhead(nperr))) return
!bi...Write intermediate results to output file:
if (WriteDebugOutput) then
call WriteModifiedArguments(InArgumentsFile, DBGD, esky, trmout, trmin, ebsky, ebroom, Gout, Gin, &
nlayer, LayerType, nmix, frct, thick, scon, gap, xgcon, xgvis, xgcp, xwght)
end if
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
! This is "solar radiation" pass
!
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!This is main calculation in case UFactor calculations will not be performed
if ((dir.gt.0.0d0).or.(SHGCCalc.eq.0)) then
! call therm1d to calculate heat flux with solar radiation
call therm1d(nlayer, iwd, tout, tind, wso, wsi, VacuumPressure, VacuumMaxGapThickness, dir, Ebsky, Gout, Trmout, Trmin, &
Ebroom, Gin, tir, rir, emis, gap, thick, scon, tilt, asol, height, heightt, width, iprop, frct, presure, &
nmix, xwght, xgcon, xgvis, xgcp, gama, SupportPillar, PillarSpacing, PillarRadius, theta, q, qv, flux, &
hcin, hrin, hcout, hrout, hin, hout, hcgas, hrgas, ufactor, nperr, ErrorMessage, tamb, troom, ibc, &
Atop, Abot, Al, Ar, Ah, vvent, tvent, LayerType, Ra, Nu, vfreevent, qcgas, qrgas, Ebf, Ebb, Rf, Rb, &
ShadeEmisRatioOut, ShadeEmisRatioIn, ShadeHcModifiedOut, ShadeHcModifiedIn, &
ThermalMod, Debug_mode, AchievedErrorToleranceSolar, NumOfIterSolar)
NumOfIterations = NumOfIterSolar
!exit on error:
if (nlayer.gt.1) then
do i=1, nlayer-1
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
if (IsShadingLayer(LayerType(i))) then
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
end if
if (IsShadingLayer(LayerType(i+1))) then
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
end if
end do
end if
if (.not.(GoAhead(nperr))) return
!No need to store results in case of non-ufactor run
if ((SHGCCalc.gt.0).and.(dir.gt.0.0d0)) then
call solarISO15099(totsol, rtot, rs, nlayer, asol, sft)
shgct = sft
shgct_NOSD = 0.0d0
hcins=hcin
hrins=hrin
hins=hin
hcouts=hcout
hrouts=hrout
houts=hout
ufactors=ufactor
fluxs=flux
do i=1,nlayer
thetas(2*i-1)=theta(2*i-1)
thetas(2*i)=theta(2*i)
Ebbs(i) = Ebb(i)
Ebfs(i) = Ebf(i)
Rbs(i) = Rb(i)
Rfs(i) = Rf(i)
qs(2*i - 1) = q(2*i - 1)
qs(2*i) = q(2*i)
!qprims(2*i - 1) = qprim(2*i - 1)
!qprims(2*i) = qprim(2*i)
qvs(2*i - 1) = qv(2*i - 1)
qvs(2*i) = qv(2*i)
hcgass(i)=hcgas(i)
hrgass(i)=hrgas(i)
qrgaps(i)=qrgas(i)
qcgaps(i)=qcgas(i)
end do
! CHECK THIS!
qs(2*nlayer+1) = q(2*nlayer+1)
end if !if (UFactorCalc.gt.0) then
end if
!No solar radiation pass is not needed to be calculated
!if ((SHGCCalc.gt.0).or.(dir.eq.0)) then
if (SHGCCalc.gt.0) then
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
! This is "no solar radiation" pass
!
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
hin=hint
hout=houtt
! call therm1d to calculate heat flux without solar radiation
call therm1d(nlayer, iwd, tout, tind, wso, wsi, VacuumPressure, VacuumMaxGapThickness, &
0.0d0, Ebsky, Gout, Trmout, Trmin, Ebroom, Gin, tir, rir, emis, gap, thick, scon, &
tilt, sol0, height, heightt, width, iprop, frct, presure, nmix, xwght, xgcon, xgvis, xgcp, gama, &
SupportPillar, PillarSpacing, PillarRadius, &
theta, q, qv, flux, hcin, hrin, hcout, hrout, hin, hout, hcgas, hrgas, ufactor, nperr, ErrorMessage, &
tamb, troom, ibc, Atop, Abot, Al, Ar, Ah, vvent, tvent, LayerType, Ra, Nu, vfreevent, qcgas, qrgas, &
Ebf, Ebb, Rf, Rb, ShadeEmisRatioOut, ShadeEmisRatioIn, ShadeHcModifiedOut, ShadeHcModifiedIn, &
ThermalMod, Debug_mode, AchievedErrorTolerance, NumOfIter)
NumOfIterations = NumOfIter
!exit on error:
if (.not.(GoAhead(nperr))) return
!bi...Keep hcout, hcin in case this is an unshaded system:
HcUnshadedOut = hcout
HcUnshadedIn = hcin
!bi...do an Unshaded run if necessary (Uvalue/Winter conditions):
!bi...Prepare variables for UNSHADED (NO SD) run:
NeedUnshadedRun = .FALSE.
FirstSpecularLayer = 1
LastSpecularLayer = nlayer
nlayer_NOSD = nlayer
if (IsShadingLayer(LayerType(1))) then
nlayer_NOSD = nlayer_NOSD - 1
FirstSpecularLayer = 2
NeedUnshadedRun = .TRUE.
end if
! if (LayerType(nlayer).eq.VENETBLIND) then
if (IsShadingLayer(LayerType(nlayer))) then
nlayer_NOSD = nlayer_NOSD-1
LastSpecularLayer = nlayer-1
NeedUnshadedRun = .TRUE.
end if
! no unshaded run for now
NeedUnshadedRun = .false.
!bi...Set outdoor & indoor gas properties:
if (NeedUnshadedRun) then
nmix_NOSD(1) = nmix(1)
presure_NOSD(1) = presure(1)
nmix_NOSD(nlayer_NOSD+1) = nmix(nlayer+1)
presure_NOSD(nlayer_NOSD+1) = presure(nlayer+1)
do j = 1, nmix(1)
iprop_NOSD(1, j) = iprop(1, j)
frct_NOSD(1, j) = frct(1, j)
end do
do j = 1, nmix(nlayer_NOSD+1)
iprop_NOSD(nlayer_NOSD+1, j) = iprop(nlayer+1, j)
frct_NOSD(nlayer_NOSD+1, j) = frct(nlayer+1, j)
end do
do i = 1, nlayer_NOSD
OriginalIndex = FirstSpecularLayer + i - 1
Atop_NOSD(i) = Atop(OriginalIndex)
Abot_NOSD(i) = Abot(OriginalIndex)
Al_NOSD(i) = Al(OriginalIndex)
Ar_NOSD(i) = Ar(OriginalIndex)
Ah_NOSD(i) = Ah(OriginalIndex)
SlatThick_NOSD(i) = SlatThick(OriginalIndex)
SlatWidth_NOSD(i) = SlatWidth(OriginalIndex)
SlatAngle_NOSD(i) = SlatAngle(OriginalIndex)
SlatCond_NOSD(i) = SlatCond(OriginalIndex)
SlatSpacing_NOSD(i) = SlatSpacing(OriginalIndex)
SlatCurve_NOSD(i) = SlatCurve(OriginalIndex)
!cbi... TO do when Forced Ventilation is implemented: take care of appropriate arguments!!!
!
! vvent_NOSD
! tvent_NOSD
!
LayerType_NOSD(i) = LayerType(OriginalIndex)
thick_NOSD(i) = thick(OriginalIndex)
scon_NOSD(i) = scon(OriginalIndex)
tir_NOSD(2*i-1) = tir(2*OriginalIndex-1)
emis_NOSD(2*i-1) = emis(2*OriginalIndex-1)
emis_NOSD(2*i) = emis(2*OriginalIndex)
rir_NOSD(2*i-1) = rir(2*OriginalIndex-1)
rir_NOSD(2*i) = rir(2*OriginalIndex)
gap_NOSD(i) = gap(OriginalIndex)
if (i < nlayer_NOSD) then
nmix_NOSD(i+1) = nmix(OriginalIndex+1)
presure_NOSD(i+1) = presure(OriginalIndex+1)
do j = 1, nmix_NOSD(i+1)
iprop_NOSD(i+1,j) = iprop(OriginalIndex+1, j)
frct_NOSD(i+1,j) = frct(OriginalIndex+1, j)
end do
end if
LaminateA_NOSD(i) = LaminateA(OriginalIndex)
LaminateB_NOSD(i) = LaminateB(OriginalIndex)
sumsol_NOSD(i) = sumsol(OriginalIndex)
nslice_NOSD(i) = nslice(OriginalIndex)
end do
! This is UNSHADED pass - no solar radiation:
hin_NOSD=hint
hout_NOSD=houtt
!Simon: Removed unshaded debug output for now
UnshadedDebug = 0
if (WriteDebugOutput.and.(UnshadedDebug.eq.1)) then
FileMode = 'APPEND'
! InArgumentsFile should already be open
!open(unit=InArgumentsFile, file=TRIM(DBGD)//DebugOutputFileName, status='unknown', access=FileMode, &
! & form='formatted', iostat=nperr)
!if (nperr.ne.0) open(unit=InArgumentsFile, file=DebugOutputFileName, status='unknown', access=FileMode, &
! & form='formatted', iostat=nperr)
write(InArgumentsFile, *)
write(InArgumentsFile, *) 'UNSHADED RUN:'
write(InArgumentsFile, *)
!close(InArgumentsFile)
call WriteInputArguments(tout, tind, trmin, wso, iwd, wsi, dir, outir, isky, tsky, esky, fclr, &
VacuumPressure, VacuumMaxGapThickness, ibc, hout_NOSD, hin_NOSD, &
ISO15099, ThermalMod, SDScalar, height, heightt, width, tilt, totsol, &
nlayer_NOSD, LayerType_NOSD, thick_NOSD, scon_NOSD, asol, tir_NOSD, emis_NOSD, &
Atop_NOSD, Abot_NOSD, Al_NOSD, Ar_NOSD, Ah_NOSD, &
SlatThick_NOSD, SlatWidth_NOSD, SlatAngle_NOSD, &
SlatCond_NOSD, SlatSpacing_NOSD, SlatCurve_NOSD, &
nslice_NOSD, LaminateA_NOSD, LaminateB_NOSD, sumsol_NOSD, &
gap_NOSD, vvent_NOSD, tvent_NOSD, &
presure_NOSD, nmix_NOSD, iprop_NOSD, frct_NOSD, &
xgcon, xgvis, xgcp, xwght)
end if ! end if UnshadedDebug = 1
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
!
! This is "Unshaded, No solar radiation" pass
!
!cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
! call therm1d to calculate heat flux with solar radiation
call therm1d(nlayer_NOSD, iwd, tout, tind, wso, wsi, VacuumPressure, VacuumMaxGapThickness, &
0.0d0, Ebsky, Gout, Trmout, Trmin, Ebroom, Gin, tir_NOSD, rir_NOSD, emis_NOSD, gap_NOSD, thick_NOSD, &
scon_NOSD, tilt, sol0, height, heightt, width, iprop_NOSD, frct_NOSD, presure_NOSD, nmix_NOSD, &
xwght, xgcon, xgvis, xgcp, gama, SupportPillar, PillarSpacing, PillarRadius, &
theta_NOSD, q_NOSD, qv_NOSD, flux_NOSD, &
hcin_NOSD, hrin_NOSD, hcout_NOSD, hrout_NOSD, hin_NOSD, hout_NOSD, &
hcgas_NOSD, hrgas_NOSD, ufactor_NOSD, nperr, ErrorMessage, tamb_NOSD, troom_NOSD, ibc, &
Atop_NOSD, Abot_NOSD, Al_NOSD, Ar_NOSD, Ah_NOSD, vvent_NOSD, tvent_NOSD, &
LayerType_NOSD, Ra_NOSD, Nu_NOSD, vfreevent_NOSD, qcgas_NOSD, qrgas_NOSD, &
Ebf_NOSD, Ebb_NOSD, Rf_NOSD, Rb_NOSD, &
ShadeEmisRatioOut_NOSD, ShadeEmisRatioIn_NOSD, ShadeHcModifiedOut_NOSD, ShadeHcModifiedIn_NOSD, &
ThermalMod, Debug_mode, AchievedErrorTolerance_NOSD, NumOfIter_NOSD)
NumOfIterations = NumOfIter_NOSD
! exit on error
if (.not.(GoAhead(nperr))) return
!bi... Keep these values:
HcUnshadedOut = hcout_NOSD
HcUnshadedIn = hcin_NOSD
ShadeHcRatioOut = ShadeHcModifiedOut / HcUnshadedOut
ShadeHcRatioIn = ShadeHcModifiedIn / HcUnshadedIn
!bi...unshaded results:
if (WriteDebugOutput.and.(UnshadedDebug.eq.1)) then
call WriteOutputArguments(OutArgumentsFile, DBGD, nlayer_NOSD, tamb, q_NOSD, qv_NOSD, qcgas_NOSD, &
qrgas_NOSD, theta_NOSD, vfreevent_NOSD, vvent_NOSD, Keff_NOSD, ShadeGapKeffConv_NOSD, &
troom_NOSD, ufactor_NOSD, shgc_NOSD, sc_NOSD, hflux_NOSD, shgct_NOSD, &
hcin_NOSD, hrin_NOSD, hcout_NOSD, hrout_NOSD, &
Ra_NOSD, Nu_NOSD, LayerType_NOSD, &
Ebf_NOSD, Ebb_NOSD, Rf_NOSD, Rb_NOSD, Ebsky, Gout, Ebroom, Gin, &
ShadeEmisRatioIn_NOSD, ShadeEmisRatioOut_NOSD, &
ShadeHcRatioIn_NOSD, ShadeHcRatioOut_NOSD, &
hcin_NOSD, hcout_NOSD, hcgas_NOSD, hrgas_NOSD, AchievedErrorTolerance_NOSD, NumOfIter_NOSD)
end if ! end if UnshadedDebug = 1
end if ! end if NeedUnshadedRun...
!bi Set T6-related quantities keff, keffc: (using non-solar pass results)
if (nlayer.gt.1) then
do i=1, nlayer-1
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
if (IsShadingLayer(LayerType(i))) then
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
end if
if (IsShadingLayer(LayerType(i+1))) then
Keff(i) = gap(i) * q(2*i+1) / (theta(2*i+1) - theta(2*i))
end if
if (IsShadingLayer(LayerType(i))) then
!Keff(i) = gap(i) * qprim(2*i+1) / (theta(2*i+1) - theta(2*i))
if ((i.gt.1).and.(i.lt.nlayer)) then
tgg = gap(i-1) + gap(i) + thick(i)
qc1 = qcgas(i-1)
qc2 = qcgas(i)
qcgg = (qc1 + qc2) / 2.0d0
ShadeGapKeffConv(i) = tgg * qcgg / (theta(2*i+1) - theta(2*i-2))
end if
end if
end do
end if
end if !if (UFactorCalc.ne.0) then
!bi... For debugging purposes:
qeff = ufactor * ABS(tout - tind)
flux_nonsolar = flux
if ((SHGCCalc.gt.0).and.(dir.gt.0.0d0)) then
shgc=totsol-(fluxs-flux)/dir
sc=shgc/0.87d0
hcin=hcins
hrin=hrins
hin=hins
hcout=hcouts
hrout=hrouts
hout=houts
flux=fluxs ! <--- ???
do i=1,nlayer
theta(2*i-1)=thetas(2*i-1)
theta(2*i)=thetas(2*i)
Ebb(i) = Ebbs(i)
Ebf(i) = Ebfs(i)
Rb(i) = Rbs(i)
Rf(i) = Rfs(i)
q(2*i - 1) = qs(2*i - 1)
q(2*i) = qs(2*i)
!qprim(2*i - 1) = qprims(2*i - 1)
!qprim(2*i) = qprims(2*i)
qv(2*i - 1) = qvs(2*i - 1)
qv(2*i) = qvs(2*i)
hcgas(i)=hcgass(i)
hrgas(i)=hrgass(i)
qcgas(i) = qcgaps(i)
qrgas(i) = qrgaps(i)
AchievedErrorTolerance = AchievedErrorToleranceSolar
NumOfIter = NumOfIterSolar
end do
! bi CHECK THIS!
q(2*nlayer+1) = qs(2*nlayer+1)
end if
hflux = flux ! save flux value for output table
!bi... Write results to debug output file:
if (WriteDebugOutput) then
call WriteOutputArguments(OutArgumentsFile, DBGD, nlayer, tamb, q, qv, qcgas, qrgas, theta, vfreevent, vvent, &
& Keff, ShadeGapKeffConv, troom, ufactor, shgc, sc, hflux, shgct, &
& hcin, hrin, hcout, hrout, Ra, Nu, LayerType, &
& Ebf, Ebb, Rf, Rb, Ebsky, Gout, Ebroom, Gin, &
& ShadeEmisRatioIn, ShadeEmisRatioOut, ShadeHcRatioIn, ShadeHcRatioOut, &
& HcUnshadedIn, HcUnshadedOut, hcgas, hrgas, AchievedErrorTolerance, NumOfIter)
end if ! if WriteDebugOutput.eq.true - writing output file
end subroutine Calc_ISO15099