-- Bring ECOTECT to the front -- if it is not already. cmd("app.activate") -- Start with a clean slate. cmd("model.new"); cmd("weather.load", "C:\\Program Files\\Square One\\Weather Data\\USA-NewYorkNewYork.wea") cmd("opengl.show", true) cmd("view.redraw") -- conversion factors f2mm = 304.8 -- convert from millimeters to feet sm2sf = 10.76 -- square meters to square feet numFloors = getUserInput("Specify Number of Floors", 1) length = getUserInput("Specify Length", 150) width = getUserInput("Specify Width", 100) coreLength = getUserInput("Specify Core Length", 30) coreWidth = getUserInput("Specify Core Width", 30) f2f = getUserInput("Specify Tower Floor to Floor:", 12) winWidth = getUserInput("Specify width of windows", 5) winHeight = getUserInput("Specify height of windows", 10) pcGlazing = getUserInput("Specify % glazing (0-1)", 0.4) -- offset from facade, used to make zones zoneOffset = 15 -- convert to model units _f2f = f2f * f2mm _towerHeight = numFloors * _f2f _length = length * f2mm _width = width * f2mm _coreLength = coreLength * f2mm _coreWidth = coreWidth * f2mm _zoneOffset = zoneOffset * f2mm _winWidth = winWidth * f2mm _winHeight = winHeight * f2mm _winArea = _winWidth * _winHeight -- window calcs _lengthArea = _f2f * _length _widthArea = _f2f * _width _lengthAreaGlass = _lengthArea * pcGlazing _widthAreaGlass = _widthArea * pcGlazing numLenWindows = floor(_lengthAreaGlass / _winArea) numWidWindows = floor(_widthAreaGlass / _winArea) --printf("lenWindows:" .. numLenWindows ) --printf("widWindows:" .. numWidWindows ) _lengthWall = _length - (numLenWindows * _winWidth) _widthWall = _width - (numWidWindows * _winWidth) _lengthMull = _lengthWall / (numLenWindows + 1) _widthMull = _widthWall / (numWidWindows + 1) _vertMull = (_f2f - _winHeight) / 2 -- arrays to hold the points used to create zones arrTower = {} arrTowerInt = {} arrTowerCore = {} -- array of zones arrZones = {} function makeFloorPts() for i = 1,numFloors+1 do _zHeight = (i-1) * f2f * f2mm zPoint = { 0, 0, zHeight } -- external tower points arrPoints = { { 0, 0, _zHeight }, { _length, 0, _zHeight }, { _length, _width, _zHeight }, { 0, _width, _zHeight } } arrTower[i] = arrPoints -- internal tower points (to make zones) arrPoints = { { _zoneOffset, _zoneOffset, _zHeight }, { _length - _zoneOffset, _zoneOffset, _zHeight }, { _length - _zoneOffset, _width - _zoneOffset, _zHeight }, { _zoneOffset, _width - _zoneOffset, _zHeight } } arrTowerInt[i] = arrPoints -- core points (to make core) arrPoints = { { _length/2 - _coreLength/2, _width/2 - _coreWidth/2, _zHeight }, { _length/2 + _coreLength/2, _width/2 - _coreWidth/2, _zHeight }, { _length/2 + _coreLength/2, _width/2 + _coreWidth/2, _zHeight }, { _length/2 - _coreLength/2, _width/2 + _coreWidth/2, _zHeight } } arrTowerCore[i] = arrPoints end end -- -- makeFloorplate -- function to create a single floorplate function makeFloorplate(flr) for i = 1,4 do if (i == 4) then j = 1 else j = i+1 end -- make zone for each wall botPts = {arrTower[flr][i], arrTower[flr][j], arrTowerInt[flr][j], arrTowerInt[flr][i]} topPts = {arrTower[flr+1][i], arrTower[flr+1][j], arrTowerInt[flr+1][j], arrTowerInt[flr+1][i]} makeZone(botPts, topPts, i, flr, "Edge") end for i = 1,4 do if (i == 4) then j = 1 else j = i+1 end -- make zone for each core wall botPts = {arrTowerInt[flr][i], arrTowerInt[flr][j], arrTowerCore[flr][j], arrTowerCore[flr][i]} topPts = {arrTowerInt[flr+1][i], arrTowerInt[flr+1][j], arrTowerCore[flr+1][j], arrTowerCore[flr+1][i]} makeZone(botPts, topPts, i, flr, "Internal") end -- center zone --botPts = {arrTowerInt[flr][1], arrTowerInt[flr][2], arrTowerInt[flr][3], arrTowerInt[flr][4]} --topPts = {arrTowerInt[flr+1][1], arrTowerInt[flr+1][2], arrTowerInt[flr+1][3], arrTowerInt[flr+1][4]} --makeZone(botPts, topPts) end -- make a zone given 8 points function makeZone(botPts, topPts, dir, flr, typ) -- create the zone thisZone = add("zone") -- name the zone if (dir==1) then strDir = "South" elseif (dir==2) then strDir = "East" elseif (dir==3) then strDir = "North" else strDir = "West" end strName = flr .. " " .. strDir .. " " .. typ printf(strName) set("zone.name", thisZone, strName) -- make it a thermal zone set("zone.thermal", thisZone, true) -- make current set("zone.current", thisZone) -- -- add geometry -- -- floor zFloor = add("object", 2, 12, True) for pt = 1,4 do x = botPts[pt][1] y = botPts[pt][2] z = botPts[pt][3] add("node", zFloor, pt-1, x, y, z) end set("object.tag", zFloor, 256) set("object.material", zFloor, 9) cmd("object.done") -- ceiling zCeiling = add("object", 3, 12, True) for pt = 1,4 do x = topPts[pt][1] y = topPts[pt][2] z = topPts[pt][3] add("node", zCeiling, pt-1, x, y, z) end set("object.tag", zCeiling, 256) set("object.material", zCeiling, 9) set("object.alternate", zCeiling, 9) cmd("object.done") -- walls windowFlag = "false" for i = 1, 4 do -- create wall if (typ == "Edge") then if (i == 1) then panel1 = add("object", 4, 12, True) else panel1 = add("object", 0, 12, True) set("object.material", panel1, 0) set("object.alternate", panel1, 0) end else if (i == 3) then panel1 = add("object", 4, 12, True) else panel1 = add("object", 0, 12, True) set("object.material", panel1, 0) set("object.alternate", panel1, 0) end end -- indexing of points if (i==4) then j = 1 else j = i+1 end -- set object type/material based on index, i.e. which side of zone if (typ == "Edge") then -- edge layer if (i==1) then -- outside of building -> add windows windowFlag = "true" panelID = panel1 zFloor = botPts[i][3] elseif (i==2 or i==3 or i==4) then -- sides and back are voids --set("object.type", panel1, 0) end elseif (typ == "Internal") then if (i==1 or i==2 or i==4) then -- sides and front are voids --set("object.type", panel1, 0) end end x = botPts[i][1] y = botPts[i][2] z = botPts[i][3] thisNode = add("node", panel1, 0, x, y, z) x = botPts[j][1] y = botPts[j][2] z = botPts[j][3] thisNode = add("node", panel1, 1, x, y, z) x = topPts[j][1] y = topPts[j][2] z = topPts[j][3] thisNode = add("node", panel1, 2, x, y, z) x = topPts[i][1] y = topPts[i][2] z = topPts[i][3] thisNode = add("node", panel1, 3, x, y, z) set("object.tag", panel1, 256) cmd("object.done") end if (windowFlag=="true") then --objIndex = get("object.index", panelID) printf("window on object " .. panelID) addWindows(panelID, dir, zFloor) windowFlag = "false" end -- add to zone array numZones = get("model.zones") arrZones[numZones-1] = thisZone end function addWindows(objIndex, dir, zFloor) if (dir==1) then -- south lenWall = _length _winY = 0 numWin = numLenWindows elseif (dir==2) then -- west lenWall = _width _winX = 0 numWin = numWidWindows elseif (dir==3) then -- north lenWall = _length _winY = _width numWin = numLenWindows else -- east lenWall = _width _winX = _length numWin = numWidWindows end _winBottom = (zFloor + _vertMull) _winTop = (zFloor + _f2f - _vertMull ) for i = 0,numWin-1 do -- create window printf("adding window #" .. i .. " direction: " .. dir) win = add("object", 6, 2444, false, objIndex); if win > -1 then printf("index:" .. win) if (dir==1 or dir==3) then _startX = ((i+1) * _lengthMull) + (i * _winWidth) _endX = ((i+1) * _lengthMull) + ((i+1) * _winWidth) x = _startX y = _winY z = _winBottom add("node", win, 0, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _endX y = _winY z = _winBottom add("node", win, 1, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _endX y = _winY z = _winTop add("node", win, 2, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _startX y = _winY z = _winTop add("node", win, 3, x, y, z) --printf(x .. "," .. y .. "," .. z) else _startY = ((i+1) * _widthMull) + (i * _winWidth) _endY = ((i+1) * _widthMull) + ((i+1) * _winWidth) x = _winX y = _startY z = _winBottom add("node", win, 0, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _winX y = _endY z = _winBottom add("node", win, 1, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _winX y = _endY z = _winTop add("node", win, 2, x, y, z) --printf(x .. "," .. y .. "," .. z) x = _winX y = _startY z = _winTop add("node", win, 3, x, y, z) --printf(x .. "," .. y .. "," .. z) end cmd("object.done") else printf("error") end end end -- -- makeTower() -- function makeTower() for i = 1, numFloors do makeFloorplate(i) printf("finished floor " .. i) cmd("view.redraw") end thisZone = add("zone") cmd("zone.delete", thisZone) set("zone.current", "1 North Edge") cmd("view.fitgrid") cmd("calc.volume") end -- -- analyzeTower() -- function analyzeTower() for i = 1, get("model.zones")-1 do str = get("zone.name", arrZones[i]) ind = get("zone.index", str) printf("Analyzing: Zone #" .. i .. ".. Name:".. str .. ".. ID:" .. ind) -- analysis set("zone.current", arrZones[i]) -- choose date set("model.date", 21, 8) -- sept 21 -- thermal gain calculation cmd("calc.thermal.gains", currentzone); for hr = 0,23 do gain = get("results.gains.2", ind, hr); -- Print out gains. printf("%6.0f\t%9.2f", hr, gain); end end end makeFloorPts() makeTower() -- analysis --analyze = getUserInput("Proceeed with analysis (type y or n)", "y") --if (analyze == "y") then analyzeTower() --end