Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | SurfNum | |||
logical, | intent(inout) | :: | ErrorsFound | |||
integer, | intent(inout) | :: | AddedSubSurfaces |
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 AddWindow(SurfNum,ErrorsFound,AddedSubSurfaces)
! SUBROUTINE INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN Nov 2008
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This routine is called from ModifyWindow to add a window. Allows it to be
! called in more than one place in the calling routine so as to be able to have
! specific warnings or errors issued.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE InputProcessor, ONLY: FindItemInList
USE General, ONLY: RoundSigDigits
USE Vectors
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: SurfNum ! SurfNum has construction of glazing system from Window5 Data File;
! If there is a second glazing systme on the Data File, SurfNum+1
! has the construction of the second glazing system.
LOGICAL, INTENT(INOUT) :: ErrorsFound ! Set to true if errors found
INTEGER, INTENT(INOUT) :: AddedSubSurfaces ! Subsurfaces added when window references a
! 2-glazing system Window5 data file entry
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
type rectangularwindow
type(vector), dimension(4) :: Vertex
end type rectangularwindow
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: TotSurfacesPrev ! Total number of surfaces before splitting window
INTEGER :: loop ! DO loop index
REAL(r64) :: H,W ! Height and width of original window (m)
REAL(r64) :: MulWidth ! Mullion width (m)
REAL(r64) :: h1,w1 ! height and width of first glazing system (m)
REAL(r64) :: h2,w2 ! height and width of second glazing system (m)
REAL(r64) :: xa,ya,za,xb,yb,zb ! Vertex intermediate variables (m)
REAL(r64) :: dx,dy ! Vertex displacements from original window (m)
type (vector) TVect
type (rectangularwindow) :: NewCoord
type (rectangularwindow) :: OriginalCoord
INTEGER :: IConst ! Construction number of first glazing system
INTEGER :: IConst2 ! Construction number of second glazing system
CHARACTER(len=MaxNameLength) :: Const2Name ! Name of construction of second glazing system
REAL(r64) :: AreaNew ! Sum of areas of the two glazing systems (m2)
IConst = SurfaceTmp(SurfNum)%Construction
! Height and width of original window
TVect=SurfaceTmp(SurfNum)%Vertex(3)-SurfaceTmp(SurfNum)%Vertex(2)
W = VecLength(TVect) !SQRT((X(3)-X(2))**2 + (Y(3)-Y(2))**2 + (Z(3)-Z(2))**2)
TVect=SurfaceTmp(SurfNum)%Vertex(2)-SurfaceTmp(SurfNum)%Vertex(1)
H = VecLength(TVect) !SQRT((X(1)-X(2))**2 + (Y(1)-Y(2))**2 + (Z(1)-Z(2))**2)
! Save coordinates of original window in case Window 5 data overwrites.
OriginalCoord%Vertex(1:SurfaceTmp(SurfNum)%Sides)=SurfaceTmp(SurfNum)%Vertex(1:SurfaceTmp(SurfNum)%Sides)
! Height and width of first glazing system
h1 = Construct(IConst)%W5FileGlazingSysHeight
w1 = Construct(IConst)%W5FileGlazingSysWidth
Const2Name = TRIM(Construct(IConst)%Name)//':2'
IConst2 = FindItemInList(Const2Name, Construct%Name,TotConstructs)
AddedSubSurfaces = AddedSubSurfaces + 1
TotSurfacesPrev = TotSurfaces
ALLOCATE(SurfaceTmpSave(TotSurfacesPrev))
DO loop = 1,TotSurfacesPrev
SurfaceTmpSave(loop) = SurfaceTmp(loop)
END DO
DEALLOCATE(SurfaceTmp)
TotSurfaces = TotSurfaces + 1
ALLOCATE(SurfaceTmp(TotSurfaces))
DO loop = 1,TotSurfacesPrev
SurfaceTmp(loop) = SurfaceTmpSave(loop)
END DO
DEALLOCATE(SurfaceTmpSave)
ALLOCATE(SurfaceTmp(TotSurfaces)%Vertex(4))
SurfaceTmp(TotSurfaces)%Name = TRIM(SurfaceTmp(SurfNum)%Name)//':2'
SurfaceTmp(TotSurfaces)%Construction = IConst2
SurfaceTmp(TotSurfaces)%ConstructionStoredInputValue = IConst2
SurfaceTmp(TotSurfaces)%Class = SurfaceTmp(SurfNum)%Class
SurfaceTmp(TotSurfaces)%Azimuth = SurfaceTmp(SurfNum)%Azimuth
! Sine and cosine of azimuth and tilt
SurfaceTmp(TotSurfaces)%SinAzim = SurfaceTmp(SurfNum)%SinAzim
SurfaceTmp(TotSurfaces)%CosAzim = SurfaceTmp(SurfNum)%CosAzim
SurfaceTmp(TotSurfaces)%SinTilt = SurfaceTmp(SurfNum)%SinTilt
SurfaceTmp(TotSurfaces)%CosTilt = SurfaceTmp(SurfNum)%CosTilt
! Outward normal unit vector (pointing away from room)
SurfaceTmp(TotSurfaces)%Centroid = SurfaceTmp(SurfNum)%Centroid
SurfaceTmp(TotSurfaces)%lcsx = SurfaceTmp(SurfNum)%lcsx
SurfaceTmp(TotSurfaces)%lcsy = SurfaceTmp(SurfNum)%lcsy
SurfaceTmp(TotSurfaces)%lcsz = SurfaceTmp(SurfNum)%lcsz
SurfaceTmp(TotSurfaces)%NewellAreaVector = SurfaceTmp(SurfNum)%NewellAreaVector
SurfaceTmp(TotSurfaces)%OutNormVec = SurfaceTmp(SurfNum)%OutNormVec
SurfaceTmp(TotSurfaces)%Reveal = SurfaceTmp(SurfNum)%Reveal
SurfaceTmp(TotSurfaces)%Shape = SurfaceTmp(SurfNum)%Shape
SurfaceTmp(TotSurfaces)%Sides = SurfaceTmp(SurfNum)%Sides
SurfaceTmp(TotSurfaces)%Tilt = SurfaceTmp(SurfNum)%Tilt
SurfaceTmp(TotSurfaces)%HeatTransSurf = SurfaceTmp(SurfNum)%HeatTransSurf
SurfaceTmp(TotSurfaces)%BaseSurfName = SurfaceTmp(SurfNum)%BaseSurfName
SurfaceTmp(TotSurfaces)%BaseSurf = SurfaceTmp(SurfNum)%BaseSurf
SurfaceTmp(TotSurfaces)%ZoneName = SurfaceTmp(SurfNum)%ZoneName
SurfaceTmp(TotSurfaces)%Zone = SurfaceTmp(SurfNum)%Zone
SurfaceTmp(TotSurfaces)%ExtBoundCondName = SurfaceTmp(SurfNum)%ExtBoundCondName
SurfaceTmp(TotSurfaces)%ExtBoundCond = SurfaceTmp(SurfNum)%ExtBoundCond
SurfaceTmp(TotSurfaces)%ExtSolar = SurfaceTmp(SurfNum)%ExtSolar
SurfaceTmp(TotSurfaces)%ExtWind = SurfaceTmp(SurfNum)%ExtWind
SurfaceTmp(TotSurfaces)%ViewFactorGround = SurfaceTmp(SurfNum)%ViewFactorGround
SurfaceTmp(TotSurfaces)%ViewFactorSky = SurfaceTmp(SurfNum)%ViewFactorSky
SurfaceTmp(TotSurfaces)%ViewFactorGroundIR = SurfaceTmp(SurfNum)%ViewFactorGroundIR
SurfaceTmp(TotSurfaces)%ViewFactorSkyIR = SurfaceTmp(SurfNum)%ViewFactorSkyIR
SurfaceTmp(TotSurfaces)%OSCPtr = SurfaceTmp(SurfNum)%OSCPtr
SurfaceTmp(TotSurfaces)%SchedShadowSurfIndex = SurfaceTmp(SurfNum)%SchedShadowSurfIndex
SurfaceTmp(TotSurfaces)%ShadowSurfSchedVaries = SurfaceTmp(SurfNum)%ShadowSurfSchedVaries
SurfaceTmp(TotSurfaces)%MaterialMovInsulExt = SurfaceTmp(SurfNum)%MaterialMovInsulExt
SurfaceTmp(TotSurfaces)%MaterialMovInsulInt = SurfaceTmp(SurfNum)%MaterialMovInsulInt
SurfaceTmp(TotSurfaces)%SchedMovInsulExt = SurfaceTmp(SurfNum)%SchedMovInsulExt
SurfaceTmp(TotSurfaces)%WindowShadingControlPtr = SurfaceTmp(SurfNum)%WindowShadingControlPtr
SurfaceTmp(TotSurfaces)%ShadedConstruction = SurfaceTmp(SurfNum)%ShadedConstruction
SurfaceTmp(TotSurfaces)%FrameDivider = SurfaceTmp(SurfNum)%FrameDivider
SurfaceTmp(TotSurfaces)%Multiplier = SurfaceTmp(SurfNum)%Multiplier
SurfaceTmp(TotSurfaces)%NetAreaShadowCalc = SurfaceTmp(SurfNum)%NetAreaShadowCalc
MulWidth = Construct(IConst)%W5FileMullionWidth
w2 = Construct(IConst2)%W5FileGlazingSysWidth
h2 = Construct(IConst2)%W5FileGlazingSysHeight
! Correction to net area of base surface. Add back in the original glazing area and subtract the
! area of the two glazing systems. Note that for Surface(SurfNum)%Class = 'Window' the effect
! of a window multiplier is included in the glazing area. Note that frame areas are subtracted later.
AreaNew = SurfaceTmp(SurfNum)%Multiplier * (h1*w1 + h2*w2) ! both glazing systems
! Adjust net area for base surface
SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%Area = &
SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%Area - AreaNew
! Net area of base surface with unity window multipliers (used in shadowing checks)
SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%NetAreaShadowCalc = &
SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%NetAreaShadowCalc - AreaNew/SurfaceTmp(SurfNum)%Multiplier
! Reset area, etc. of original window
SurfaceTmp(SurfNum)%Area = SurfaceTmp(SurfNum)%Multiplier * (h1*w1)
SurfaceTmp(SurfNum)%GrossArea = SurfaceTmp(SurfNum)%Area
SurfaceTmp(SurfNum)%NetAreaShadowCalc = h1*w1
SurfaceTmp(SurfNum)%Perimeter = 2*(h1+w1)
SurfaceTmp(SurfNum)%Height = h1
SurfaceTmp(SurfNum)%Width = w1
! Set area, etc. of new window
SurfaceTmp(TotSurfaces)%Area = SurfaceTmp(TotSurfaces)%Multiplier * (h2*w2)
SurfaceTmp(TotSurfaces)%GrossArea = SurfaceTmp(TotSurfaces)%Area
SurfaceTmp(TotSurfaces)%NetAreaShadowCalc = h2*w2
SurfaceTmp(TotSurfaces)%Perimeter = 2*(h2+w2)
SurfaceTmp(TotSurfaces)%Height = h2
SurfaceTmp(TotSurfaces)%Width = w2
IF (SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%Area <= 0.0d0) THEN
CALL ShowSevereError('SurfaceGeometry: ModifyWindow: Subsurfaces have too much area for base surface='// &
TRIM(SurfaceTmp(SurfaceTmp(SurfNum)%BaseSurf)%Name))
CALL ShowContinueError('Subsurface (window) creating error='//TRIM(SurfaceTmp(SurfNum)%Name))
CALL ShowContinueError('This window has been replaced by two windows from the Window5 Data File of total area '// &
TRIM(RoundSigDigits(AreaNew,2))//' m2')
ErrorsFound=.true.
ENDIF
! Assign vertices to the new window; modify vertices of original window.
! In the following, vertices are numbered counter-clockwise with vertex #1 at the upper left.
IF(Construct(IConst)%W5FileMullionOrientation == Vertical) THEN
! VERTICAL MULLION: original window is modified to become left-hand glazing (system #1);
! new window is created to become right-hand glazing (system #2)
! Left-hand glazing
! Vertex 1
dx = 0.0d0
dy = H - h1
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(1)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(1)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(1)%z = za + (dx/W)*(zb-za)
! Vertex 2
dx = 0.0d0
dy = H
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(2)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(2)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(2)%z = za + (dx/W)*(zb-za)
! Vertex 3
dx = w1
dy = H
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(3)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(3)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(3)%z = za + (dx/W)*(zb-za)
! Vertex 4
dx = w1
dy = H - h1
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(4)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(4)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(4)%z = za + (dx/W)*(zb-za)
DO loop = 1,SurfaceTmp(SurfNum)%Sides
SurfaceTmp(SurfNum)%Vertex(loop) = NewCoord%Vertex(loop)
END DO
! Right-hand glazing
! Vertex 1
dx = w1 + MulWidth
dy = H - (h1+h2)/2.0d0
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(1)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(1)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(1)%z = za + (dx/W)*(zb-za)
! Vertex 2
dx = w1 + MulWidth
dy = H + (h2-h1)/2.0d0
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(2)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(2)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(2)%z = za + (dx/W)*(zb-za)
! Vertex 3
dx = w1 + MulWidth + w2
dy = H + (h2-h1)/2.0d0
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(3)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(3)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(3)%z = za + (dx/W)*(zb-za)
! Vertex 4
dx = w1 + MulWidth + w2
dy = H - (h1+h2)/2.0d0
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(4)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(4)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(4)%z = za + (dx/W)*(zb-za)
DO loop = 1,SurfaceTmp(TotSurfaces)%Sides
SurfaceTmp(TotSurfaces)%Vertex(loop) = NewCoord%Vertex(loop)
END DO
ELSE ! Horizontal mullion
! HORIZONTAL MULLION: original window is modified to become bottom glazing (system #1);
! new window is created to become top glazing (system #2)
! Bottom glazing
! Vertex 1
dx = 0.0d0
dy = H - h1
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(1)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(1)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(1)%z = za + (dx/W)*(zb-za)
! Vertex 2
dx = 0.0d0
dy = H
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(2)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(2)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(2)%z = za + (dx/W)*(zb-za)
! Vertex 3
dx = w1
dy = H
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(3)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(3)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(3)%z = za + (dx/W)*(zb-za)
! Vertex 4
dx = w1
dy = H - h1
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(4)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(4)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(4)%z = za + (dx/W)*(zb-za)
DO loop = 1,SurfaceTmp(SurfNum)%Sides
SurfaceTmp(SurfNum)%Vertex(loop) = NewCoord%Vertex(loop)
END DO
! Top glazing
! Vertex 1
dx = (w1 - w2)/2.0d0
dy = H - (h1+h2+MulWidth)
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(1)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(1)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(1)%z = za + (dx/W)*(zb-za)
! Vertex 2
dx = (w1 - w2)/2.0d0
dy = H - (h1+MulWidth)
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(2)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(2)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(2)%z = za + (dx/W)*(zb-za)
! Vertex 3
dx = (w1 + w2)/2.0d0
dy = H - (h1+MulWidth)
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(3)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(3)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(3)%z = za + (dx/W)*(zb-za)
! Vertex 4
dx = (w1 + w2)/2.0d0
dy = H - (h1+h2+MulWidth)
xa = OriginalCoord%Vertex(1)%x + (dy/H)*(OriginalCoord%Vertex(2)%x-OriginalCoord%Vertex(1)%x)
ya = OriginalCoord%Vertex(1)%y + (dy/H)*(OriginalCoord%Vertex(2)%y-OriginalCoord%Vertex(1)%y)
za = OriginalCoord%Vertex(1)%z + (dy/H)*(OriginalCoord%Vertex(2)%z-OriginalCoord%Vertex(1)%z)
xb = OriginalCoord%Vertex(4)%x + (dy/H)*(OriginalCoord%Vertex(3)%x-OriginalCoord%Vertex(4)%x)
yb = OriginalCoord%Vertex(4)%y + (dy/H)*(OriginalCoord%Vertex(3)%y-OriginalCoord%Vertex(4)%y)
zb = OriginalCoord%Vertex(4)%z + (dy/H)*(OriginalCoord%Vertex(3)%z-OriginalCoord%Vertex(4)%z)
NewCoord%Vertex(4)%x = xa + (dx/W)*(xb-xa)
NewCoord%Vertex(4)%y = ya + (dx/W)*(yb-ya)
NewCoord%Vertex(4)%z = za + (dx/W)*(zb-za)
DO loop = 1,SurfaceTmp(TotSurfaces)%Sides
SurfaceTmp(TotSurfaces)%Vertex(loop) = NewCoord%Vertex(loop)
END DO
END IF ! End of check if vertical or horizontal mullion
RETURN
END SUBROUTINE AddWindow