Class: OpenStudio::Model::Space
- Inherits:
-
Object
- Object
- OpenStudio::Model::Space
- Defined in:
- lib/openstudio-standards/standards/Standards.Space.rb
Overview
open the class to add methods to apply HVAC efficiency standards
Instance Method Summary collapse
-
#a_polygons_minus_b_polygons(a_polygons, b_polygons, a_name, b_name) ⇒ Object
private
Subtracts one array of polygons from the next, returning an array of resulting polygons.
-
#addDaylightingControls(vintage, remove_existing_controls, draw_daylight_areas_for_debugging = false) ⇒ Hash
Adds daylighting controls (sidelighting and toplighting) per the standard.
-
#area_a_polygons_overlap_b_polygons(a_polygons, b_polygons, a_name, b_name) ⇒ Object
private
Returns an array of resulting polygons.
-
#check_z_zero(polygons, name, space) ⇒ Object
private
Check the z coordinates of a polygon.
-
#component_infiltration_rate(template) ⇒ Double
Determine the component infiltration rate for this space.
-
#daylighted_areas(vintage, draw_daylight_areas_for_debugging = false) ⇒ Hash
Returns values for the different types of daylighted areas in the space.
-
#exterior_wall_and_window_area ⇒ Double
Calculate the area of the exterior walls, including the area of the windows on these walls.
-
#find_duplicate_vertices(ruby_polygon, tol = 0.001) ⇒ Object
private
A method to returns the number of duplicate vertices in a polygon.
-
#is_plenum ⇒ Object
Determine if the space is a plenum.
-
#is_residential(standard) ⇒ Object
Determine if the space is residential based on the space type properties for the space.
-
#join_polygons(polygons, tol, name) ⇒ Object
private
Wrapper to catch errors in joinAll method [utilities.geometry.joinAll] <1> Expected polygons to join together.
-
#polygons_set_z(polygons, new_z) ⇒ Object
private
A method to zero-out the z vertex of an array of polygons.
-
#ruby_polygons_to_point3d_z_zero(ruby_polygons) ⇒ Object
private
A method to convert an array of arrays to an array of OpenStudio::Point3ds.
-
#set_infiltration_rate(template) ⇒ Double
Set the infiltration rate for this space to include the impact of air leakage requirements in the standard.
-
#sidelightingEffectiveAperture(primary_sidelighted_area) ⇒ Double
Returns the sidelighting effective aperture sidelighting_effective_aperture = E(window area * window VT) / primary_sidelighted_area.
-
#skylightEffectiveAperture(toplighted_area) ⇒ Double
Returns the skylight effective aperture skylight_effective_aperture = E(0.85 * skylight area * skylight VT * WF) / toplighted_area.
-
#total_area_of_polygons(polygons) ⇒ Object
private
Gets the total area of a series of polygons.
Instance Method Details
#a_polygons_minus_b_polygons(a_polygons, b_polygons, a_name, b_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Subtracts one array of polygons from the next, returning an array of resulting polygons.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 119 def a_polygons_minus_b_polygons(a_polygons, b_polygons, a_name, b_name) final_polygons_ruby = [] OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "#{a_polygons.size} #{a_name} minus #{b_polygons.size} #{b_name}") # Don't try to subtract anything if either set is empty if a_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} - #{b_name}: #{a_name} contains no polygons.") return polygons_set_z(a_polygons, 0.0) elsif b_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} - #{b_name}: #{b_name} contains no polygons.") return polygons_set_z(a_polygons, 0.0) end # Loop through all a polygons, and for each one, # subtract all the b polygons. a_polygons.each do |a_polygon| # Translate the polygon to plain arrays a_polygon_ruby = [] a_polygon.each do |vertex| a_polygon_ruby << [vertex.x, vertex.y, vertex.z] end # TODO Skip really small polygons # reduced_b_polygons = [] # b_polygons.each do |b_polygon| # next # end # Perform the subtraction a_minus_b_polygons = OpenStudio.subtract(a_polygon, b_polygons, 0.01) # Translate the resulting polygons to plain ruby arrays a_minus_b_polygons_ruby = [] num_small_polygons = 0 a_minus_b_polygons.each do |a_minus_b_polygon| # Drop any super small or zero-vertex polygons resulting from the subtraction area = OpenStudio.getArea(a_minus_b_polygon) if area.is_initialized if area.get < 0.5 # 5 square feet num_small_polygons += 1 next end else num_small_polygons += 1 next end # Translate polygon to ruby array a_minus_b_polygon_ruby = [] a_minus_b_polygon.each do |vertex| a_minus_b_polygon_ruby << [vertex.x, vertex.y, vertex.z] end a_minus_b_polygons_ruby << a_minus_b_polygon_ruby end if num_small_polygons > 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Dropped #{num_small_polygons} small or invalid polygons resulting from subtraction.") end # Remove duplicate polygons unique_a_minus_b_polygons_ruby = a_minus_b_polygons_ruby.uniq OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Remove duplicates: #{a_minus_b_polygons_ruby.size} ==> #{unique_a_minus_b_polygons_ruby.size}") # TODO bug workaround? # If the result includes the a polygon, the a polygon # was unchanged; only include that polgon and throw away the other junk?/bug? polygons. # If the result does not include the a polygon, the a polygon was # split into multiple pieces. Keep all those pieces. if unique_a_minus_b_polygons_ruby.include?(a_polygon_ruby) if unique_a_minus_b_polygons_ruby.size == 1 final_polygons_ruby.concat([a_polygon_ruby]) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---includes only original polygon, keeping that one") else # Remove the original polygon unique_a_minus_b_polygons_ruby.delete(a_polygon_ruby) final_polygons_ruby.concat(unique_a_minus_b_polygons_ruby) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---includes the original and others; keeping all other polygons") end else final_polygons_ruby.concat(unique_a_minus_b_polygons_ruby) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---does not include original, keeping all resulting polygons") end end # Remove duplicate polygons again unique_final_polygons_ruby = final_polygons_ruby.uniq # TODO remove this workaround # Split any polygons that are joined by a line into two separate # polygons. Do this by finding duplicate # unique_final_polygons_ruby.each do |unique_final_polygon_ruby| # next if unique_final_polygon_ruby.size == 4 # Don't check 4-sided polygons # dupes = find_duplicate_vertices(unique_final_polygon_ruby) # if dupes.size > 0 # OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "---Two polygons attached by line = #{unique_final_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # end # end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Remove final duplicates: #{final_polygons_ruby.size} ==> #{unique_final_polygons_ruby.size}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} minus #{b_name} = #{unique_final_polygons_ruby.size} polygons.") # Convert the final polygons back to OpenStudio unique_final_polygons = ruby_polygons_to_point3d_z_zero(unique_final_polygons_ruby) return unique_final_polygons end |
#addDaylightingControls(vintage, remove_existing_controls, draw_daylight_areas_for_debugging = false) ⇒ Hash
add a list of valid choices for vintage argument
add exception for retail spaces
add exception 2 for skylights with VT < 0.4
add exception 3 for CZ 8 where lighting < 200W
stop skipping non-vertical walls
stop skipping non-horizontal roofs
Determine the illuminance setpoint for the controls based on space type
rotate sensor to face window (only needed for glare calcs)
This method is super complicated because of all the polygon/geometry math required. and therefore may not return perfect results. However, it works well in most tested situations. When it fails, it will log warnings/errors for users to see.
Adds daylighting controls (sidelighting and toplighting) per the standard
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1229 def addDaylightingControls(vintage, remove_existing_controls, draw_daylight_areas_for_debugging = false) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "******For #{self.name}, adding daylight controls.") # Check for existing daylighting controls # and remove if specified in the input existing_daylighting_controls = self.daylightingControls if existing_daylighting_controls.size > 0 if remove_existing_controls existing_daylighting_controls.each do |dc| dc.remove end OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, removed #{existing_daylighting_controls.size} existing daylight controls before adding new controls.") else OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, daylight controls were already present, no additional controls added.") return false end end areas = nil req_top_ctrl = false req_pri_ctrl = false req_sec_ctrl = false # Get the area of the space space_area_m2 = self.floorArea # Get the LPD of the space space_lpd_w_per_m2 = self.lightingPowerPerFloorArea # Determine the type of control required case vintage when 'DOE Ref Pre-1980', 'DOE Ref 1980-2004', '90.1-2004', '90.1-2007' # Do nothing, no daylighting controls required OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, daylighting control not required by this standard.") return false when '90.1-2010' req_top_ctrl = true req_pri_ctrl = true areas = self.daylighted_areas(vintage, draw_daylight_areas_for_debugging) ################### OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "primary_sidelighted_area = #{areas['primary_sidelighted_area']}") ################### # Sidelighting # Check if the primary sidelit area < 250 ft2 if areas['primary_sidelighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because primary sidelighted area = 0ft2 per 9.4.1.4.") req_pri_ctrl = false elsif areas['primary_sidelighted_area'] < OpenStudio.convert(250, 'ft^2', 'm^2').get OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because primary sidelighted area < 250ft2 per 9.4.1.4.") req_pri_ctrl = false else # Check effective sidelighted aperture sidelighted_effective_aperture = self.sidelightingEffectiveAperture(areas['primary_sidelighted_area']) ################### OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "sidelighted_effective_aperture_pri = #{sidelighted_effective_aperture}") ################### if sidelighted_effective_aperture < 0.1 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because sidelighted effective aperture < 0.1 per 9.4.1.4 Exception b.") req_pri_ctrl = false else # TODO Check the space type # if # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, primary sidelighting control not required because space type is retail per 9.4.1.4 Exception c.") # req_pri_ctrl = false # end end end ################### OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "toplighted_area = #{areas['toplighted_area']}") ################### # Toplighting # Check if the toplit area < 900 ft2 if areas['toplighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because toplighted area = 0ft2 per 9.4.1.5.") req_top_ctrl = false elsif areas['toplighted_area'] < OpenStudio.convert(900, 'ft^2', 'm^2').get OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because toplighted area < 900ft2 per 9.4.1.5.") req_top_ctrl = false else # Check effective sidelighted aperture sidelighted_effective_aperture = self.skylightEffectiveAperture(areas['toplighted_area']) ################### OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "sidelighted_effective_aperture_top = #{sidelighted_effective_aperture}") ################### if sidelighted_effective_aperture < 0.006 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because skylight effective aperture < 0.006 per 9.4.1.5 Exception b.") req_top_ctrl = false else # TODO Check the climate zone. Not required in CZ8 where toplit areas < 1500ft2 # if # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, toplighting control not required because space type is retail per 9.4.1.5 Exception c.") # req_top_ctrl = false # end end end when '90.1-2013' req_top_ctrl = true req_pri_ctrl = true req_sec_ctrl = true areas = self.daylighted_areas(vintage, draw_daylight_areas_for_debugging) # Primary Sidelighting # Check if the primary sidelit area contains less than 150W of lighting if areas['primary_sidelighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because primary sidelighted area = 0ft2 per 9.4.1.1(e).") req_pri_ctrl = false elsif areas['primary_sidelighted_area'] * space_lpd_w_per_m2 < 150.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because less than 150W of lighting are present in the primary daylighted area per 9.4.1.1(e).") req_pri_ctrl = false else # Check the size of the windows if areas['total_window_area'] < 20.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because there are less than 20ft2 of window per 9.4.1.1(e) Exception 2.") req_pri_ctrl = false else # TODO Check the space type # if # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because space type is retail per 9.4.1.1(e) Exception c.") # req_pri_ctrl = false # end end end # Secondary Sidelighting # Check if the primary and secondary sidelit areas contains less than 300W of lighting if areas['secondary_sidelighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, secondary sidelighting control not required because secondary sidelighted area = 0ft2 per 9.4.1.1(e).") req_pri_ctrl = false elsif (areas['primary_sidelighted_area'] + areas['secondary_sidelighted_area']) * space_lpd_w_per_m2 < 300 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, secondary sidelighting control not required because less than 300W of lighting are present in the combined primary and secondary daylighted areas per 9.4.1.1(e).") req_sec_ctrl = false else # Check the size of the windows if areas['total_window_area'] < 20 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, secondary sidelighting control not required because there are less than 20ft2 of window per 9.4.1.1(e) Exception 2.") req_sec_ctrl = false else # TODO Check the space type # if # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because space type is retail per 9.4.1.1(e) Exception c.") # req_sec_ctrl = false # end end end # Toplighting # Check if the toplit area contains less than 150W of lighting if areas['toplighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because toplighted area = 0ft2 per 9.4.1.1(f).") req_pri_ctrl = false elsif areas['toplighted_area'] * space_lpd_w_per_m2 < 150 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because less than 150W of lighting are present in the toplighted area per 9.4.1.1(f).") req_sec_ctrl = false else # TODO exception 2 for skylights with VT < 0.4 # TODO exception 3 for CZ 8 where lighting < 200W end when 'AssetScore' # Same as 90.1-2010 but without effective aperture limits # to avoid needing to perform run to get VLT for layered windows. req_top_ctrl = true req_pri_ctrl = true areas = self.daylighted_areas(vintage, draw_daylight_areas_for_debugging) # Sidelighting # Check if the primary sidelit area < 250 ft2 if areas['primary_sidelighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because primary sidelighted area = 0ft2 per 9.4.1.4.") req_pri_ctrl = false elsif areas['primary_sidelighted_area'] < OpenStudio.convert(250, 'ft^2', 'm^2').get OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control not required because primary sidelighted area < 250ft2 per 9.4.1.4.") req_pri_ctrl = false end # Toplighting # Check if the toplit area < 900 ft2 if areas['toplighted_area'] == 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because toplighted area = 0ft2 per 9.4.1.5.") req_top_ctrl = false elsif areas['toplighted_area'] < OpenStudio.convert(900, 'ft^2', 'm^2').get OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control not required because toplighted area < 900ft2 per 9.4.1.5.") req_top_ctrl = false end end # End of vintage case statement # Output the daylight control requirements OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, toplighting control required = #{req_top_ctrl}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, primary sidelighting control required = #{req_pri_ctrl}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, secondary sidelighting control required = #{req_sec_ctrl}") # Stop here if no lighting controls are required. # Do not put daylighting control points into the space. if !req_top_ctrl && !req_pri_ctrl && !req_sec_ctrl OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, no daylighting control is required.") return false end # Record a floor in the space for later use floor_surface = nil self.surfaces.sort.each do |surface| if surface.surfaceType == "Floor" floor_surface = surface break end end # Find all exterior windows/skylights in the space and record their azimuths and areas windows = {} skylights = {} self.surfaces.sort.each do |surface| next unless surface.outsideBoundaryCondition == "Outdoors" && (surface.surfaceType == "Wall" || surface.surfaceType == "RoofCeiling") # Skip non-vertical walls and non-horizontal roofs straight_upward = OpenStudio::Vector3d.new(0, 0, 1) surface_normal = surface.outwardNormal if surface.surfaceType == "Wall" # TODO stop skipping non-vertical walls unless surface_normal.z.abs < 0.001 if surface.subSurfaces.size > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Cannot currently handle non-vertical walls; skipping windows on #{surface.name} in #{self.name} for daylight sensor positioning.") next end end elsif surface.surfaceType == "RoofCeiling" # TODO stop skipping non-horizontal roofs unless surface_normal.to_s == straight_upward.to_s if surface.subSurfaces.size > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{self.name} for daylight sensor positioning.") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Surface #{surface.name} has outward normal of #{surface_normal.to_s.gsub(/\[|\]/,'|')}; up is #{straight_upward.to_s.gsub(/\[|\]/,'|')}.") next end end end # Find the azimuth of the facade facade = nil group = surface.planarSurfaceGroup if group.is_initialized group = group.get site_transformation = group.buildingTransformation site_vertices = site_transformation * surface.vertices site_outward_normal = OpenStudio::getOutwardNormal(site_vertices) if site_outward_normal.empty? OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Could not compute outward normal for #{surface.name.get}") next end site_outward_normal = site_outward_normal.get north = OpenStudio::Vector3d.new(0.0,1.0,0.0) if site_outward_normal.x < 0.0 azimuth = 360.0 - OpenStudio::radToDeg(OpenStudio::getAngle(site_outward_normal, north)) else azimuth = OpenStudio::radToDeg(OpenStudio::getAngle(site_outward_normal, north)) end else # The surface is not in a group; should not hit, since # called from Space.surfaces next end #TODO modify to work for buildings in the southern hemisphere? if (azimuth >= 315.0 || azimuth < 45.0) facade = "4-North" elsif (azimuth >= 45.0 && azimuth < 135.0) facade = "3-East" elsif (azimuth >= 135.0 && azimuth < 225.0) facade = "1-South" elsif (azimuth >= 225.0 && azimuth < 315.0) facade = "2-West" end # Label the facade as "Up" if it is a skylight if surface_normal.to_s == straight_upward.to_s facade = "0-Up" end # Loop through all subsurfaces and surface.subSurfaces.sort.each do |sub_surface| next unless sub_surface.outsideBoundaryCondition == "Outdoors" && (sub_surface.subSurfaceType == "FixedWindow" || sub_surface.subSurfaceType == "OperableWindow" || sub_surface.subSurfaceType == "Skylight") # Find the area net_area_m2 = sub_surface.netArea # Find the head height and sill height of the window vertex_heights_above_floor = [] sub_surface.vertices.each do |vertex| vertex_on_floorplane = floor_surface.plane.project(vertex) vertex_heights_above_floor << (vertex - vertex_on_floorplane).length end head_height_m = vertex_heights_above_floor.max #OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "---head height = #{head_height_m}m, sill height = #{sill_height_m}m") # Log the window properties to use when creating daylight sensors properties = {:facade => facade, :area_m2 => net_area_m2, :handle => sub_surface.handle, :head_height_m => head_height_m, :name => sub_surface.name.get.to_s} if facade == '0-Up' skylights[sub_surface] = properties else windows[sub_surface] = properties end end #next sub-surface end #next surface # Determine the illuminance setpoint for the controls based on space type # From IESNA Handbook 10th Edition - Applications daylight_stpt_lux = 300 =begin space_type = self.space_type if space_type.empty? OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Space #{space.name} is an unknown space type, assuming Office and 300 Lux daylight setpoint") else space_type = space_type.get std_spc_type = space_type.standardsSpaceType if std_spc_type.empty? OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Space #{space.name} does not have a defined standards space type, assuming Office and 300 Lux daylight setpoint") else std_spc_type = std_spc_type.get case std_spc_type when Storage = 50 Corridor = 50 Corridor2 = 50 when PatCorridor = 100 'Banquet = 100 Basement = 100 Cafe = 100 Lobby = 100 when Dining = 150 GuestRoom = 150 GuestRoom2 = 150 GuestRoom3 = 150 GuestRoom4 = 150 when Mechanical = 200 Retail = 200 Retail2 = 200 when Laundry = 300 Office = 300 when ER_NurseStn = 500 ICU_Open = 500 ICU_PatRm = 500 Kitchen = 500 Lab = 500 NurseStn = 500 ICU_NurseStn = 500 PatRoom = 500 PhysTherapy = 500 Radiology = 500 when ER_Exam = 1000 ER_Trauma = 1000 ER_Triage = 1000 when OR = 2000 FullServiceRestaurant.Dining FullServiceRestaurant Hospital.Corridor Hospital.Dining Hospital.ER_Exam Hospital.ER_NurseStn Hospital.ER_Trauma Hospital.ER_Triage Hospital.ICU_NurseStn Hospital.ICU_Open Hospital.ICU_PatRm Hospital.Kitchen Hospital.Lab Hospital.Lobby Hospital.NurseStn Hospital.Office Hospital.OR Hospital.PatCorridor Hospital.PatRoom Hospital.PhysTherapy Hospital.Radiology LargeHotel.Banquet LargeHotel.Basement LargeHotel.Cafe LargeHotel.Corridor LargeHotel.Corridor2 LargeHotel.GuestRoom LargeHotel.GuestRoom2 LargeHotel.GuestRoom3 LargeHotel.GuestRoom4 LargeHotel.Kitchen LargeHotel.Laundry LargeHotel.Lobby LargeHotel.Mechanical LargeHotel.Retail LargeHotel.Retail2 LargeHotel.Storage MidriseApartment.Apartment MidriseApartment.Corridor MidriseApartment.Office Office Office.Attic Office.BreakRoom Office.ClosedOffice Office.Conference Office.Corridor Office.Elec/MechRoom Office.IT_Room Office.Lobby Office.OpenOffice Office.PrintRoom Office.Restroom Office.Stair Office.Storage Office.Vending Office.WholeBuilding - Lg Office Office.WholeBuilding - Md Office Office.WholeBuilding - Sm Office Outpatient.Anesthesia Outpatient.BioHazard Outpatient.Cafe Outpatient.CleanWork Outpatient.Conference Outpatient.DressingRoom Outpatient.Elec/MechRoom Outpatient.Exam Outpatient.Hall Outpatient.IT_Room Outpatient.Janitor Outpatient.Lobby Outpatient.LockerRoom Outpatient.Lounge Outpatient.MedGas Outpatient.MRI Outpatient.MRI_Control Outpatient.NurseStation Outpatient.Office Outpatient.OR Outpatient.PACU Outpatient.PhysicalTherapy Outpatient.PreOp Outpatient.ProcedureRoom Outpatient.Soil Work Outpatient.Stair Outpatient.Toilet Outpatient.Xray PrimarySchool.Cafeteria PrimarySchool.Classroom PrimarySchool.Corridor PrimarySchool.Gym PrimarySchool.Kitchen PrimarySchool.Library PrimarySchool.Lobby PrimarySchool.Mechanical PrimarySchool.Office PrimarySchool.Restroom QuickServiceRestaurant.Dining QuickServiceRestaurant.Kitchen Retail.Back_Space Retail.Entry Retail.Point_of_Sale Retail.Retail SecondarySchool.Auditorium SecondarySchool.Cafeteria SecondarySchool.Classroom SecondarySchool.Corridor SecondarySchool.Gym SecondarySchool.Kitchen SecondarySchool.Library SecondarySchool.Lobby SecondarySchool.Mechanical SecondarySchool.Office SecondarySchool.Restroom SmallHotel.Attic SmallHotel.Corridor SmallHotel.Corridor4 SmallHotel.Elec/MechRoom SmallHotel.ElevatorCore SmallHotel.ElevatorCore4 SmallHotel.Exercise SmallHotel.GuestLounge SmallHotel.GuestRoom SmallHotel.GuestRoom123Occ SmallHotel.GuestRoom123Vac SmallHotel.GuestRoom4Occ SmallHotel.GuestRoom4Vac SmallHotel.Laundry SmallHotel.Mechanical SmallHotel.Meeting SmallHotel.Office SmallHotel.PublicRestroom SmallHotel.StaffLounge SmallHotel.Stair SmallHotel.Stair4 SmallHotel.Storage SmallHotel.Storage4 StripMall.WholeBuilding SuperMarket.Deli/Bakery SuperMarket.DryStorage SuperMarket.Office SuperMarket.Sales/Produce Warehouse.Bulk Warehouse.Fine Warehouse.Office if std_spc_type.match(/post-office/i)# Post Office 500 Lux daylight_stpt_lux = 500 elsif std_spc_type.match(/medical-office/i)# Medical Office 3000 Lux daylight_stpt_lux = 3000 elsif std_spc_type.match(/office/i)# Office 500 Lux daylight_stpt_lux = 500 elsif std_spc_type.match(/education/i)# School 500 Lux daylight_stpt_lux = 500 elsif std_spc_type.match(/retail/i)# Retail 1000 Lux daylight_stpt_lux = 1000 elsif std_spc_type.match(/warehouse/i)# Warehouse 200 Lux daylight_stpt_lux = 200 elsif std_spc_type.match(/hotel/i)# Hotel 300 Lux daylight_stpt_lux = 300 elsif std_spc_type.match(/multifamily/i)# Apartment 200 Lux daylight_stpt_lux = 200 elsif std_spc_type.match(/courthouse/i)# Courthouse 300 Lux daylight_stpt_lux = 300 elsif std_spc_type.match(/library/i)# Library 500 Lux daylight_stpt_lux = 500 elsif std_spc_type.match(/community-center/i)# Community Center 300 Lux daylight_stpt_lux = 300 elsif std_spc_type.match(/senior-center/i)# Senior Center 1000 Lux daylight_stpt_lux = 1000 elsif std_spc_type.match(/city-hall/i)# City Hall 500 Lux daylight_stpt_lux = 500 else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Space #{std_spc_type} is an unknown space type, assuming office and 300 Lux daylight setpoint") daylight_stpt_lux = 300 end end end =end # Get the zone that the space is in zone = self.thermalZone if zone.empty? OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Space #{self.name.get} has no thermal zone") else zone = zone.get end # Sort by priority; first by facade, then by area, # then by name to ensure deterministic in case identical in other ways sorted_windows = windows.sort_by { |window, vals| [vals[:facade], vals[:area], vals[:name]] } sorted_skylights = skylights.sort_by { |skylight, vals| [vals[:facade], vals[:area], vals[:name]] } # Report out the sorted skylights for debugging OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, Skylights:") sorted_skylights.each do |sky, p| OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{sky.name} #{p[:facade]}, area = #{p[:area_m2].round(2)} m^2") end # Report out the sorted windows for debugging OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{vintage} #{self.name}, Windows:") sorted_windows.each do |win, p| OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{win.name} #{p[:facade]}, area = #{p[:area_m2].round(2)} m^2") end # Add the required controls sensor_1_frac = 0.0 sensor_2_frac = 0.0 sensor_1_window = nil sensor_2_window = nil case vintage when 'DOE Ref Pre-1980', 'DOE Ref 1980-2004', '90.1-2004', '90.1-2007' # Do nothing, no daylighting controls required when '90.1-2010', 'AssetScore' if req_top_ctrl && req_pri_ctrl # Sensor 1 controls toplighted area sensor_1_frac = areas['toplighted_area']/space_area_m2 sensor_1_window = sorted_skylights[0] # Sensor 2 controls primary area sensor_2_frac = areas['primary_sidelighted_area']/space_area_m2 sensor_2_window = sorted_windows[0] elsif req_top_ctrl && !req_pri_ctrl # Sensor 1 controls toplighted area sensor_1_frac = areas['toplighted_area']/space_area_m2 sensor_1_window = sorted_skylights[0] elsif !req_top_ctrl && req_pri_ctrl if sorted_windows.size == 1 # Sensor 1 controls the whole primary area sensor_1_frac = areas['primary_sidelighted_area']/space_area_m2 sensor_1_window = sorted_windows[0] else # Sensor 1 controls half the primary area sensor_1_frac = (areas['primary_sidelighted_area']/space_area_m2)/2 sensor_1_window = sorted_windows[0] # Sensor 2 controls the other half of primary area sensor_2_frac = (areas['primary_sidelighted_area']/space_area_m2)/2 sensor_2_window = sorted_windows[1] end end when '90.1-2013' if req_top_ctrl && req_pri_ctrl && req_sec_ctrl # Sensor 1 controls toplighted area sensor_1_frac = areas['toplighted_area']/space_area_m2 sensor_1_window = sorted_skylights[0] # Sensor 2 controls primary + secondary area sensor_2_frac = (areas['primary_sidelighted_area'] + areas['secondary_sidelighted_area'])/space_area_m2 sensor_2_window = sorted_windows[0] elsif !req_top_ctrl && req_pri_ctrl && req_sec_ctrl # Sensor 1 controls primary area sensor_1_frac = areas['primary_sidelighted_area']/space_area_m2 sensor_1_window = sorted_windows[0] # Sensor 2 controls secondary area sensor_2_frac = (areas['secondary_sidelighted_area']/space_area_m2)/2 sensor_2_window = sorted_windows[0] elsif req_top_ctrl && !req_pri_ctrl && req_sec_ctrl # Sensor 1 controls toplighted area sensor_1_frac = areas['toplighted_area']/space_area_m2 sensor_1_window = sorted_skylights[0] # Sensor 2 controls secondary area sensor_2_frac = (areas['secondary_sidelighted_area']/space_area_m2)/2 sensor_2_window = sorted_windows[0] elsif req_top_ctrl && !req_pri_ctrl && !req_sec_ctrl # Sensor 1 controls toplighted area sensor_1_frac = areas['toplighted_area']/space_area_m2 sensor_1_window = sorted_skylights[0] elsif !req_top_ctrl && req_pri_ctrl && !req_sec_ctrl # Sensor 1 controls primary area sensor_1_frac = areas['primary_sidelighted_area']/space_area_m2 sensor_1_window = sorted_windows[0] elsif !req_top_ctrl && !req_pri_ctrl && req_sec_ctrl # Sensor 1 controls secondary area sensor_1_frac = areas['secondary_sidelighted_area']/space_area_m2 sensor_1_window = sorted_windows[0] end end # End of vintage case statement # Place the sensors and set control fractions # get the zone that the space is in zone = self.thermalZone if zone.empty? OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Space #{self.name}, cannot determine daylighted areas.") return false else zone = self.thermalZone.get end # Sensors OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, sensor 1 fraction = #{sensor_1_frac.round(2)}.") OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{vintage} #{self.name}, sensor 2 fraction = #{sensor_2_frac.round(2)}.") # First sensor if sensor_1_window # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, calculating daylighted areas.") # runner.registerInfo("Daylight sensor 1 inside of #{sensor_1_frac.name}") sensor_1 = OpenStudio::Model::DaylightingControl.new(model) sensor_1.setName("#{self.name} Daylt Sensor 1") sensor_1.setSpace(self) sensor_1.setIlluminanceSetpoint(daylight_stpt_lux) sensor_1.setLightingControlType("Stepped") sensor_1.setNumberofSteppedControlSteps(3) #all sensors 3-step per design # Place sensor depending on skylight or window sensor_vertex = nil if sensor_1_window[1][:facade] == '0-Up' sub_surface = sensor_1_window[0] outward_normal = sub_surface.outwardNormal centroid = OpenStudio::getCentroid(sub_surface.vertices).get ht_above_flr = OpenStudio::convert(3.0, "ft", "m").get outward_normal.setLength(sensor_1_window[1][:head_height_m] - ht_above_flr) sensor_vertex = centroid + outward_normal.reverseVector else sub_surface = sensor_1_window[0] window_outward_normal = sub_surface.outwardNormal window_centroid = OpenStudio::getCentroid(sub_surface.vertices).get window_outward_normal.setLength(sensor_1_window[1][:head_height_m]) vertex = window_centroid + window_outward_normal.reverseVector vertex_on_floorplane = floor_surface.plane.project(vertex) floor_outward_normal = floor_surface.outwardNormal floor_outward_normal.setLength(OpenStudio::convert(3.0, "ft", "m").get) sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector end sensor_1.setPosition(sensor_vertex) #TODO rotate sensor to face window (only needed for glare calcs) zone.setPrimaryDaylightingControl(sensor_1) zone.setFractionofZoneControlledbyPrimaryDaylightingControl(sensor_1_frac) end # Second sensor if sensor_2_window # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "For #{self.name}, calculating daylighted areas.") # runner.registerInfo("Daylight sensor 2 inside of #{sensor_2_frac.name}") sensor_2 = OpenStudio::Model::DaylightingControl.new(model) sensor_2.setName("#{self.name} Daylt Sensor 2") sensor_2.setSpace(self) sensor_2.setIlluminanceSetpoint(daylight_stpt_lux) sensor_2.setLightingControlType("Stepped") sensor_2.setNumberofSteppedControlSteps(3) #all sensors 3-step per design # Place sensor depending on skylight or window sensor_vertex = nil if sensor_2_window[1][:facade] == '0-Up' sub_surface = sensor_2_window[0] outward_normal = sub_surface.outwardNormal centroid = OpenStudio::getCentroid(sub_surface.vertices).get ht_above_flr = OpenStudio::convert(3.0, "ft", "m").get outward_normal.setLength(sensor_2_window[1][:head_height_m] - ht_above_flr) sensor_vertex = centroid + outward_normal.reverseVector else sub_surface = sensor_2_window[0] window_outward_normal = sub_surface.outwardNormal window_centroid = OpenStudio::getCentroid(sub_surface.vertices).get window_outward_normal.setLength(sensor_2_window[1][:head_height_m]) vertex = window_centroid + window_outward_normal.reverseVector vertex_on_floorplane = floor_surface.plane.project(vertex) floor_outward_normal = floor_surface.outwardNormal floor_outward_normal.setLength(OpenStudio::convert(3.0, "ft", "m").get) sensor_vertex = vertex_on_floorplane + floor_outward_normal.reverseVector end sensor_2.setPosition(sensor_vertex) #TODO rotate sensor to face window (only needed for glare calcs) zone.setSecondaryDaylightingControl(sensor_2) zone.setFractionofZoneControlledbySecondaryDaylightingControl(sensor_2_frac) end return true end |
#area_a_polygons_overlap_b_polygons(a_polygons, b_polygons, a_name, b_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an array of resulting polygons. Assumes that a_polygons don’t overlap one another, and that b_polygons don’t overlap one another
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 350 def area_a_polygons_overlap_b_polygons(a_polygons, b_polygons, a_name, b_name) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "#{a_polygons.size} #{a_name} overlaps #{b_polygons.size} #{b_name}") overlap_area = 0 # Don't try anything if either set is empty if a_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} overlaps #{b_name}: #{a_name} contains no polygons.") return overlap_area elsif b_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} overlaps #{b_name}: #{b_name} contains no polygons.") return overlap_area end # Loop through each base surface b_polygons.each do |b_polygon| # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "---b polygon = #{b_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # Loop through each overlap surface and determine if it overlaps this base surface a_polygons.each do |a_polygon| # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "------a polygon = #{a_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # If the entire a polygon is within the b polygon, count 100% of the area # as overlapping and remove a polygon from the list if OpenStudio.within(a_polygon, b_polygon, 0.01) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a overlaps b ENTIRELY.") area = OpenStudio.getArea(a_polygon) if area.is_initialized overlap_area += area.get next else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Could not determine the area of #{a_polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end # If part of a polygon overlaps b polygon, determine the # original area of polygon b, subtract polygon a from b, # then add the difference in area to the total. elsif OpenStudio.intersects(a_polygon, b_polygon, 0.01) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a overlaps b PARTIALLY.") # Get the initial area area_initial = 0 area = OpenStudio.getArea(b_polygon) if area.is_initialized area_initial = area.get else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Could not determine the area of #{a_polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end # Perform the subtraction b_minus_a_polygons = OpenStudio.subtract(b_polygon, [a_polygon], 0.01) # Get the final area area_final = 0 b_minus_a_polygons.each do |polygon| # Skip polygons that have no vertices # resulting from the subtraction. if polygon.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Zero-vertex polygon resulting from #{b_polygon.to_s.gsub(/\[|\]/,'|')} minus #{a_polygon.to_s.gsub(/\[|\]/,'|')}.") next end # Find the area of real polygons area = OpenStudio.getArea(polygon) if area.is_initialized area_final += area.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Could not determine the area of #{polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end end # Add the diference to the total overlap_area += (area_initial - area_final) # There is no overlap else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a does not overlaps b at all.") end end end return overlap_area end |
#check_z_zero(polygons, name, space) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check the z coordinates of a polygon
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 29 def check_z_zero(polygons, name, space) fails = [] errs = 0 polygons.each do |polygon| #OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Checking z=0: #{name} => #{polygon.to_s.gsub(/\[|\]/,'|')}.") polygon.each do |vertex| #clsss << vertex.class unless vertex.z == 0.0 errs += 1 fails << vertex.z end end end #OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Checking z=0: #{name} => #{clsss.uniq.to_s.gsub(/\[|\]/,'|')}.") if errs > 0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "***FAIL*** #{space} z=0 failed for #{errs} vertices in #{name}; #{fails.join(', ')}.") end end |
#component_infiltration_rate(template) ⇒ Double
handle floors over unconditioned spaces
make subsurface infil rates part of Surface.component_infiltration_rate?
Determine the component infiltration rate for this space
2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 2090 def component_infiltration_rate(template) # Define the total building baseline infiltration rate basic_infil_rate_cfm_per_ft2 = nil infil_type = nil case template when 'DOE Ref Pre-1980', 'DOE Ref 1980-2004' OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "For #{template}, infiltration rates are not defined using this method, no changes have been made to the model.") return true when '90.1-2004', '90.1-2007' basic_infil_rate_cfm_per_ft2 = 1.8 when '90.1-2010', '90.1-2013' basic_infil_rate_cfm_per_ft2 = 1.0 end # Calculate the basic infiltration rate ext_area_m2 = self.exteriorArea ext_area_ft2 = OpenStudio.convert(ext_area_m2,'m^2','ft^2').get basic_infil_cfm = basic_infil_rate_cfm_per_ft2 * ext_area_ft2 basic_infil_m3_per_s = OpenStudio.convert(basic_infil_cfm,'cfm','m^3/s').get # Calculate the baseline component infiltration rate infil_type = 'baseline' base_comp_infil_m3_per_s = 0.0 self.surfaces.sort.each do |surface| # This surface base_comp_infil_m3_per_s += surface.component_infiltration_rate(infil_type) # Subsurfaces in this surface # TODO make this part of Surface.component_infiltration_rate? surface.subSurfaces.sort.each do |subsurface| base_comp_infil_m3_per_s += subsurface.component_infiltration_rate(infil_type) end end base_comp_infil_cfm = OpenStudio.convert(base_comp_infil_m3_per_s,'m^3/s','cfm').get # Calculate the advanced component infiltration rate infil_type = 'advanced' adv_comp_infil_m3_per_s = 0.0 self.surfaces.sort.each do |surface| # This surface adv_comp_infil_m3_per_s += surface.component_infiltration_rate(infil_type) # Subsurfaces in this surface # TODO make this part of Surface.component_infiltration_rate? surface.subSurfaces.sort.each do |subsurface| adv_comp_infil_m3_per_s += subsurface.component_infiltration_rate(infil_type) end end adv_comp_infil_cfm = OpenStudio.convert(adv_comp_infil_m3_per_s,'m^3/s','cfm').get # Calculate the adjusted infiltration rate infil_m3_per_s = basic_infil_m3_per_s - base_comp_infil_m3_per_s + adv_comp_infil_m3_per_s # Adjust the infiltration from 75Pa to 4Pa intial_pressure_pa = 75.0 final_pressure_pa = 4.0 adj_infil_m3_per_s = adjust_infiltration_to_lower_pressure(infil_m3_per_s, intial_pressure_pa, final_pressure_pa, ) # Calculate the rate per exterior area adj_infil_m3_per_s_per_m2 = adj_infil_m3_per_s / ext_area_m2 OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}, infil = #{adj_infil_m3_per_s_per_m2.round(8)} m^3/s*m^2.") #=> infil = #{comp_infil_rate_m3_per_s.round(2)} m^3/s, ext area = #{tot_ext_area_m2.round} m^2") #OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}, comp infil = #{comp_infil_rate_cfm_per_ft2.round(4)} cfm/ft2 => infil = #{comp_infil_rate_cfm.round(2)} cfm, ext area = #{tot_ext_area_ft2.round} ft2") #OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}") return adj_infil_m3_per_s end |
#daylighted_areas(vintage, draw_daylight_areas_for_debugging = false) ⇒ Hash
add a list of valid choices for vintage argument
This method is super complicated because of all the polygon/geometry math required. and therefore may not return perfect results. However, it works well in most tested situations. When it fails, it will log warnings/errors for users to see.
Returns values for the different types of daylighted areas in the space. Definitions for each type of area follow the respective standard.
TODO stop skipping non-vertical walls
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 21 def daylighted_areas(vintage, draw_daylight_areas_for_debugging = false) # A series of methods to modify polygons. Most are # wrappers of native OpenStudio methods, but with # workarounds for known issues or limitations. # Check the z coordinates of a polygon # @api private def check_z_zero(polygons, name, space) fails = [] errs = 0 polygons.each do |polygon| #OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Checking z=0: #{name} => #{polygon.to_s.gsub(/\[|\]/,'|')}.") polygon.each do |vertex| #clsss << vertex.class unless vertex.z == 0.0 errs += 1 fails << vertex.z end end end #OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Checking z=0: #{name} => #{clsss.uniq.to_s.gsub(/\[|\]/,'|')}.") if errs > 0 OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "***FAIL*** #{space} z=0 failed for #{errs} vertices in #{name}; #{fails.join(', ')}.") end end # A method to convert an array of arrays to # an array of OpenStudio::Point3ds. # @api private def ruby_polygons_to_point3d_z_zero(ruby_polygons) # Convert the final polygons back to OpenStudio os_polygons = [] ruby_polygons.each do |ruby_polygon| os_polygon = [] ruby_polygon.each do |vertex| vertex = OpenStudio::Point3d.new(vertex[0], vertex[1], 0.0) # Set z to hard-zero instead of vertex[2] os_polygon << vertex end os_polygons << os_polygon end return os_polygons end # A method to zero-out the z vertex of an array of polygons # @api private def polygons_set_z(polygons, new_z) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "### #{polygons}") # Convert the final polygons back to OpenStudio new_polygons = [] polygons.each do |polygon| new_polygon = [] polygon.each do |vertex| new_vertex = OpenStudio::Point3d.new(vertex.x, vertex.y, new_z) # Set z to hard-zero instead of vertex[2] new_polygon << new_vertex end new_polygons << new_polygon end return new_polygons end # A method to returns the number of duplicate vertices in a polygon. # TODO does not actually wor # @api private def find_duplicate_vertices(ruby_polygon, tol = 0.001) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***") duplicates = [] combos = ruby_polygon.combination(2).to_a OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "########{combos.size}") combos.each do |i, j| i_vertex = OpenStudio::Point3d.new(i[0], i[1], i[2]) j_vertex = OpenStudio::Point3d.new(j[0], j[1], j[2]) distance = OpenStudio.getDistance(i_vertex, j_vertex) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "------- #{i.to_s} to #{j.to_s} = #{distance}") if distance < tol duplicates << i end end return duplicates end # Subtracts one array of polygons from the next, # returning an array of resulting polygons. # @api private def a_polygons_minus_b_polygons(a_polygons, b_polygons, a_name, b_name) final_polygons_ruby = [] OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "#{a_polygons.size} #{a_name} minus #{b_polygons.size} #{b_name}") # Don't try to subtract anything if either set is empty if a_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} - #{b_name}: #{a_name} contains no polygons.") return polygons_set_z(a_polygons, 0.0) elsif b_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} - #{b_name}: #{b_name} contains no polygons.") return polygons_set_z(a_polygons, 0.0) end # Loop through all a polygons, and for each one, # subtract all the b polygons. a_polygons.each do |a_polygon| # Translate the polygon to plain arrays a_polygon_ruby = [] a_polygon.each do |vertex| a_polygon_ruby << [vertex.x, vertex.y, vertex.z] end # TODO Skip really small polygons # reduced_b_polygons = [] # b_polygons.each do |b_polygon| # next # end # Perform the subtraction a_minus_b_polygons = OpenStudio.subtract(a_polygon, b_polygons, 0.01) # Translate the resulting polygons to plain ruby arrays a_minus_b_polygons_ruby = [] num_small_polygons = 0 a_minus_b_polygons.each do |a_minus_b_polygon| # Drop any super small or zero-vertex polygons resulting from the subtraction area = OpenStudio.getArea(a_minus_b_polygon) if area.is_initialized if area.get < 0.5 # 5 square feet num_small_polygons += 1 next end else num_small_polygons += 1 next end # Translate polygon to ruby array a_minus_b_polygon_ruby = [] a_minus_b_polygon.each do |vertex| a_minus_b_polygon_ruby << [vertex.x, vertex.y, vertex.z] end a_minus_b_polygons_ruby << a_minus_b_polygon_ruby end if num_small_polygons > 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Dropped #{num_small_polygons} small or invalid polygons resulting from subtraction.") end # Remove duplicate polygons unique_a_minus_b_polygons_ruby = a_minus_b_polygons_ruby.uniq OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Remove duplicates: #{a_minus_b_polygons_ruby.size} ==> #{unique_a_minus_b_polygons_ruby.size}") # TODO bug workaround? # If the result includes the a polygon, the a polygon # was unchanged; only include that polgon and throw away the other junk?/bug? polygons. # If the result does not include the a polygon, the a polygon was # split into multiple pieces. Keep all those pieces. if unique_a_minus_b_polygons_ruby.include?(a_polygon_ruby) if unique_a_minus_b_polygons_ruby.size == 1 final_polygons_ruby.concat([a_polygon_ruby]) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---includes only original polygon, keeping that one") else # Remove the original polygon unique_a_minus_b_polygons_ruby.delete(a_polygon_ruby) final_polygons_ruby.concat(unique_a_minus_b_polygons_ruby) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---includes the original and others; keeping all other polygons") end else final_polygons_ruby.concat(unique_a_minus_b_polygons_ruby) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---does not include original, keeping all resulting polygons") end end # Remove duplicate polygons again unique_final_polygons_ruby = final_polygons_ruby.uniq # TODO remove this workaround # Split any polygons that are joined by a line into two separate # polygons. Do this by finding duplicate # unique_final_polygons_ruby.each do |unique_final_polygon_ruby| # next if unique_final_polygon_ruby.size == 4 # Don't check 4-sided polygons # dupes = find_duplicate_vertices(unique_final_polygon_ruby) # if dupes.size > 0 # OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "---Two polygons attached by line = #{unique_final_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # end # end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Remove final duplicates: #{final_polygons_ruby.size} ==> #{unique_final_polygons_ruby.size}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} minus #{b_name} = #{unique_final_polygons_ruby.size} polygons.") # Convert the final polygons back to OpenStudio unique_final_polygons = ruby_polygons_to_point3d_z_zero(unique_final_polygons_ruby) return unique_final_polygons end # Wrapper to catch errors in joinAll method # [utilities.geometry.joinAll] <1> Expected polygons to join together # @api private def join_polygons(polygons, tol, name) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Joining #{name} from #{self.name}") combined_polygons = [] # Don't try to combine an empty array of polygons if polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{name} contains no polygons, not combining.") return combined_polygons end # Open a log msg_log = OpenStudio::StringStreamLogSink.new msg_log.setLogLevel(OpenStudio::Info) # Combine the polygons combined_polygons = OpenStudio.joinAll(polygons, 0.01) # Count logged errors join_errs = 0 inner_loop_errs = 0 msg_log.logMessages.each do |msg| if /utilities.geometry/.match(msg.logChannel) if msg.logMessage.include?("Expected polygons to join together") join_errs += 1 elsif msg.logMessage.include?("Union has inner loops") inner_loop_errs += 1 end end end # TODO remove this workaround, which is tried if there # are any join errors. This handles the case of polygons # that make an inner loop, the most common case being # when all 4 sides of a space have windows. # If an error occurs, attempt to join n-1 polygons, # then subtract the if join_errs > 0 || inner_loop_errs > 0 # Open a log msg_log_2 = OpenStudio::StringStreamLogSink.new msg_log_2.setLogLevel(OpenStudio::Info) first_polygon = polygons.first polygons = polygons.drop(1) combined_polygons_2 = OpenStudio.joinAll(polygons, 0.01) join_errs_2 = 0 inner_loop_errs_2 = 0 msg_log_2.logMessages.each do |msg| if /utilities.geometry/.match(msg.logChannel) if msg.logMessage.include?("Expected polygons to join together") join_errs_2 += 1 elsif msg.logMessage.include?("Union has inner loops") inner_loop_errs_2 += 1 end end end if join_errs_2 > 0 || inner_loop_errs_2 > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, the workaround for joining polygons failed.") else # First polygon minus the already combined polygons first_polygon_minus_combined = a_polygons_minus_b_polygons([first_polygon], combined_polygons_2, 'first_polygon', 'combined_polygons_2') # Add the result back combined_polygons_2 += first_polygon_minus_combined combined_polygons = combined_polygons_2 join_errs = 0 inner_loop_errs = 0 end end # Report logged errors to user if join_errs > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, #{join_errs} of #{polygons.size} #{name} were not joined properly due to limitations of the geometry calculation methods. The resulting daylighted areas will be smaller than they should be.") end if inner_loop_errs > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, #{inner_loop_errs} of #{polygons.size} #{name} were not joined properly becasue the joined polygons have an internal hole. The resulting daylighted areas will be smaller than they should be.") end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Joined #{polygons.size} #{name} into #{combined_polygons.size} polygons.") return combined_polygons end # Gets the total area of a series of polygons # @api private def total_area_of_polygons(polygons) total_area_m2 = 0 polygons.each do |polygon| area_m2 = OpenStudio.getArea(polygon) if area_m2.is_initialized total_area_m2 += area_m2.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Could not get area for a polygon in #{self.name}, daylighted area calculation will not be accurate.") end end return total_area_m2 end # Returns an array of resulting polygons. # Assumes that a_polygons don't overlap one another, and that b_polygons don't overlap one another # @api private def area_a_polygons_overlap_b_polygons(a_polygons, b_polygons, a_name, b_name) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "#{a_polygons.size} #{a_name} overlaps #{b_polygons.size} #{b_name}") overlap_area = 0 # Don't try anything if either set is empty if a_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} overlaps #{b_name}: #{a_name} contains no polygons.") return overlap_area elsif b_polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{a_name} overlaps #{b_name}: #{b_name} contains no polygons.") return overlap_area end # Loop through each base surface b_polygons.each do |b_polygon| # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "---b polygon = #{b_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # Loop through each overlap surface and determine if it overlaps this base surface a_polygons.each do |a_polygon| # OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "------a polygon = #{a_polygon_ruby.to_s.gsub(/\[|\]/,'|')}") # If the entire a polygon is within the b polygon, count 100% of the area # as overlapping and remove a polygon from the list if OpenStudio.within(a_polygon, b_polygon, 0.01) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a overlaps b ENTIRELY.") area = OpenStudio.getArea(a_polygon) if area.is_initialized overlap_area += area.get next else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Could not determine the area of #{a_polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end # If part of a polygon overlaps b polygon, determine the # original area of polygon b, subtract polygon a from b, # then add the difference in area to the total. elsif OpenStudio.intersects(a_polygon, b_polygon, 0.01) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a overlaps b PARTIALLY.") # Get the initial area area_initial = 0 area = OpenStudio.getArea(b_polygon) if area.is_initialized area_initial = area.get else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Could not determine the area of #{a_polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end # Perform the subtraction b_minus_a_polygons = OpenStudio.subtract(b_polygon, [a_polygon], 0.01) # Get the final area area_final = 0 b_minus_a_polygons.each do |polygon| # Skip polygons that have no vertices # resulting from the subtraction. if polygon.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Zero-vertex polygon resulting from #{b_polygon.to_s.gsub(/\[|\]/,'|')} minus #{a_polygon.to_s.gsub(/\[|\]/,'|')}.") next end # Find the area of real polygons area = OpenStudio.getArea(polygon) if area.is_initialized area_final += area.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Could not determine the area of #{polygon.to_s.gsub(/\[|\]/,'|')} in #{a_name}; #{a_name} overlaps #{b_name}.") end end # Add the diference to the total overlap_area += (area_initial - area_final) # There is no overlap else OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---------a does not overlaps b at all.") end end end return overlap_area end ### Begin the actual daylight area calculations ### OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "For #{self.name}, calculating daylighted areas.") result = {'toplighted_area' => nil, 'primary_sidelighted_area' => nil, 'secondary_sidelighted_area' => nil, 'total_window_area' => nil, 'total_skylight_area' => nil } total_window_area = 0 total_skylight_area = 0 # Make rendering colors to help debug visually if draw_daylight_areas_for_debugging # Yellow toplit_construction = OpenStudio::Model::Construction.new(model) toplit_color = OpenStudio::Model::RenderingColor.new(model) toplit_color.setRenderingRedValue(255) toplit_color.setRenderingGreenValue(255) toplit_color.setRenderingBlueValue(0) toplit_construction.setRenderingColor(toplit_color) # Red pri_sidelit_construction = OpenStudio::Model::Construction.new(model) pri_sidelit_color = OpenStudio::Model::RenderingColor.new(model) pri_sidelit_color.setRenderingRedValue(255) pri_sidelit_color.setRenderingGreenValue(0) pri_sidelit_color.setRenderingBlueValue(0) pri_sidelit_construction.setRenderingColor(pri_sidelit_color) # Blue sec_sidelit_construction = OpenStudio::Model::Construction.new(model) sec_sidelit_color = OpenStudio::Model::RenderingColor.new(model) sec_sidelit_color.setRenderingRedValue(0) sec_sidelit_color.setRenderingGreenValue(0) sec_sidelit_color.setRenderingBlueValue(255) sec_sidelit_construction.setRenderingColor(sec_sidelit_color) # Light Blue flr_construction = OpenStudio::Model::Construction.new(model) flr_color = OpenStudio::Model::RenderingColor.new(model) flr_color.setRenderingRedValue(0) flr_color.setRenderingGreenValue(255) flr_color.setRenderingBlueValue(255) flr_construction.setRenderingColor(flr_color) end # Move the polygon up slightly for viewability in sketchup up_translation_flr = OpenStudio::createTranslation(OpenStudio::Vector3d.new(0, 0, 0.05)) up_translation_top = OpenStudio::createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1)) up_translation_pri = OpenStudio::createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1)) up_translation_sec = OpenStudio::createTranslation(OpenStudio::Vector3d.new(0, 0, 0.1)) # Get the space's surface group's transformation @space_transformation = self.transformation # Record a floor in the space for later use floor_surface = nil # Record all floor polygons floor_polygons = [] floor_z = 0.0 self.surfaces.sort.each do |surface| if surface.surfaceType == "Floor" floor_surface = surface floor_z = surface.vertices[0].z # floor_polygons << surface.vertices # Hard-set the z for the floor to zero new_floor_polygon = [] surface.vertices.each do |vertex| new_floor_polygon << OpenStudio::Point3d.new(vertex.x, vertex.y, 0.0) end floor_polygons << new_floor_polygon end end # Make sure there is one floor surface if floor_surface.nil? OpenStudio::logFree(OpenStudio::Error, "openstudio.model.Space", "Could not find a floor in space #{self.name.get}, cannot determine daylighted areas.") return result end # Make a set of vertices representing each subsurfaces sidelighteding area # and fold them all down onto the floor of the self. toplit_polygons = [] pri_sidelit_polygons = [] sec_sidelit_polygons = [] self.surfaces.sort.each do |surface| if surface.outsideBoundaryCondition == "Outdoors" && surface.surfaceType == "Wall" # TODO stop skipping non-vertical walls surface_normal = surface.outwardNormal surface_normal_z = surface_normal.z unless surface_normal_z.abs < 0.001 if surface.subSurfaces.size > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Cannot currently handle non-vertical walls; skipping windows on #{surface.name} in #{self.name}.") next end end surface.subSurfaces.sort.each do |sub_surface| next unless sub_surface.outsideBoundaryCondition == "Outdoors" && (sub_surface.subSurfaceType == "FixedWindow" || sub_surface.subSurfaceType == "OperableWindow") #OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***#{sub_surface.name}***" total_window_area += sub_surface.netArea # Find the head height and sill height of the window vertex_heights_above_floor = [] sub_surface.vertices.each do |vertex| vertex_on_floorplane = floor_surface.plane.project(vertex) vertex_heights_above_floor << (vertex - vertex_on_floorplane).length end sill_height_m = vertex_heights_above_floor.min head_height_m = vertex_heights_above_floor.max #OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "head height = #{head_height_m.round(2)}m, sill height = #{sill_height_m.round(2)}m") # Find the width of the window rot_origin = nil if not sub_surface.vertices.size == 4 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "A sub-surface in space #{self.name} has other than 4 vertices; this sub-surface will not be included in the daylighted area calculation.") next end prev_vertex_on_floorplane = nil max_window_width_m = 0 sub_surface.vertices.each do |vertex| vertex_on_floorplane = floor_surface.plane.project(vertex) if not prev_vertex_on_floorplane prev_vertex_on_floorplane = vertex_on_floorplane next end width_m = (prev_vertex_on_floorplane - vertex_on_floorplane).length if width_m > max_window_width_m max_window_width_m = width_m rot_origin = vertex_on_floorplane end end # Determine the extra width to add to the sidelighted area extra_width_m = 0 if vintage == '90.1-2013' extra_width_m = head_height_m / 2 elsif vintage == '90.1-2010' extra_width_m = OpenStudio.convert(2, 'ft', 'm').get end #OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Adding #{extra_width_m.round(2)}m to the width for the sidelighted area.") # Align the vertices with face coordinate system face_transform = OpenStudio::Transformation.alignFace(sub_surface.vertices) aligned_vertices = face_transform.inverse * sub_surface.vertices # Find the min and max x values min_x_val = 99999 max_x_val = -99999 aligned_vertices.each do |vertex| # Min x value if vertex.x < min_x_val min_x_val = vertex.x end # Max x value if vertex.x > max_x_val max_x_val = vertex.x end end #OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "min_x_val = #{min_x_val.round(2)}, max_x_val = #{max_x_val.round(2)}") # Create polygons that are adjusted # to expand from the window shape to the sidelighteded areas. pri_sidelit_sub_polygon = [] sec_sidelit_sub_polygon = [] aligned_vertices.each do |vertex| # Primary sidelighted area # Move the x vertices outward by the specified amount. if vertex.x == min_x_val new_x = vertex.x - extra_width_m elsif vertex.x == max_x_val new_x = vertex.x + extra_width_m else new_x = 99.9 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "A window in space #{self.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.") end # Zero-out the y for the bottom edge because the # sidelighteding area extends down to the floor. if vertex.y == 0 new_y = vertex.y - sill_height_m else new_y = vertex.y end # Set z = 0 so that intersection works. new_z = 0.0 # Make the new vertex new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z) pri_sidelit_sub_polygon << new_vertex #OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "#{vertex.x.round(2)}, #{vertex.y.round(2)}, #{vertex.z.round(2)} ==> #{new_vertex.x.round(2)}, #{new_vertex.y.round(2)}, #{new_vertex.z.round(2)}") # Secondary sidelighted area # Move the x vertices outward by the specified amount. if vertex.x == min_x_val new_x = vertex.x - extra_width_m elsif vertex.x == max_x_val new_x = vertex.x + extra_width_m else new_x = 99.9 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "A window in space #{self.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.") end # Add the head height of the window to all points # sidelighteding area extends down to the floor. if vertex.y == 0 new_y = vertex.y - sill_height_m + head_height_m else new_y = vertex.y + head_height_m end # Set z = 0 so that intersection works. new_z = 0.0 # Make the new vertex new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z) sec_sidelit_sub_polygon << new_vertex end # Realign the vertices with space coordinate system pri_sidelit_sub_polygon = face_transform * pri_sidelit_sub_polygon sec_sidelit_sub_polygon = face_transform * sec_sidelit_sub_polygon # Rotate the sidelighteded areas down onto the floor down_vector = OpenStudio::Vector3d.new(0, 0, -1) outward_normal_vector = sub_surface.outwardNormal rot_vector = down_vector.cross(outward_normal_vector) ninety_deg_in_rad = OpenStudio::degToRad(90) # TODO change new_rotation = OpenStudio::createRotation(rot_origin, rot_vector, ninety_deg_in_rad) pri_sidelit_sub_polygon = new_rotation * pri_sidelit_sub_polygon sec_sidelit_sub_polygon = new_rotation * sec_sidelit_sub_polygon # Put the polygon vertices into counterclockwise order pri_sidelit_sub_polygon = pri_sidelit_sub_polygon.reverse sec_sidelit_sub_polygon = sec_sidelit_sub_polygon.reverse # Add these polygons to the list pri_sidelit_polygons << pri_sidelit_sub_polygon sec_sidelit_polygons << sec_sidelit_sub_polygon end # Next subsurface elsif surface.outsideBoundaryCondition == "Outdoors" && surface.surfaceType == "RoofCeiling" # TODO stop skipping non-horizontal roofs surface_normal = surface.outwardNormal straight_upward = OpenStudio::Vector3d.new(0, 0, 1) unless surface_normal.to_s == straight_upward.to_s if surface.subSurfaces.size > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Cannot currently handle non-horizontal roofs; skipping skylights on #{surface.name} in #{self.name}.") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Surface #{surface.name} has outward normal of #{surface_normal.to_s.gsub(/\[|\]/,'|')}; up is #{straight_upward.to_s.gsub(/\[|\]/,'|')}.") next end end surface.subSurfaces.sort.each do |sub_surface| next unless sub_surface.outsideBoundaryCondition == "Outdoors" && sub_surface.subSurfaceType == "Skylight" #OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***#{sub_surface.name}***") total_skylight_area += sub_surface.netArea # Project the skylight onto the floor plane polygon_on_floor = [] vertex_heights_above_floor = [] sub_surface.vertices.each do |vertex| vertex_on_floorplane = floor_surface.plane.project(vertex) vertex_heights_above_floor << (vertex - vertex_on_floorplane).length polygon_on_floor << vertex_on_floorplane end # Determine the ceiling height. # Assumes skylight is flush with ceiling. ceiling_height_m = vertex_heights_above_floor.max # Align the vertices with face coordinate system face_transform = OpenStudio::Transformation.alignFace(polygon_on_floor) aligned_vertices = face_transform.inverse * polygon_on_floor # Find the min and max x and y values min_x_val = 99999 max_x_val = -99999 min_y_val = 99999 max_y_val = -99999 aligned_vertices.each do |vertex| # Min x value if vertex.x < min_x_val min_x_val = vertex.x end # Max x value if vertex.x > max_x_val max_x_val = vertex.x end # Min y value if vertex.y < min_y_val min_y_val = vertex.y end # Max y value if vertex.y > max_x_val max_y_val = vertex.y end end # Figure out how much to expand the window additional_extent_m = 0.7 * ceiling_height_m # Create polygons that are adjusted # to expand from the window shape to the sidelighteded areas. toplit_sub_polygon = [] aligned_vertices.each do |vertex| # Move the x vertices outward by the specified amount. if vertex.x == min_x_val new_x = vertex.x - additional_extent_m elsif vertex.x == max_x_val new_x = vertex.x + additional_extent_m else new_x = 99.9 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "A skylight in space #{self.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.") end # Move the y vertices outward by the specified amount. if vertex.y == min_y_val new_y = vertex.y - additional_extent_m elsif vertex.y == max_y_val new_y = vertex.y + additional_extent_m else new_y = 99.9 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "A skylight in space #{self.name} is non-rectangular; this sub-surface will not be included in the daylighted area calculation.") end # Set z = 0 so that intersection works. new_z = 0.0 # Make the new vertex new_vertex = OpenStudio::Point3d.new(new_x, new_y, new_z) toplit_sub_polygon << new_vertex end # Realign the vertices with space coordinate system toplit_sub_polygon = face_transform * toplit_sub_polygon # Put the polygon vertices into counterclockwise order toplit_sub_polygon = toplit_sub_polygon.reverse # Add these polygons to the list toplit_polygons << toplit_sub_polygon end # Next subsurface end # End if outdoor wall or roofceiling end # Next surface # Set z=0 for all the polygons so that intersection will work toplit_polygons = polygons_set_z(toplit_polygons, 0.0) pri_sidelit_polygons = polygons_set_z(pri_sidelit_polygons, 0.0) sec_sidelit_polygons = polygons_set_z(sec_sidelit_polygons, 0.0) # Check the initial polygons check_z_zero(floor_polygons, 'floor_polygons', self.name.get) check_z_zero(toplit_polygons, 'toplit_polygons', self.name.get) check_z_zero(pri_sidelit_polygons, 'pri_sidelit_polygons', self.name.get) check_z_zero(sec_sidelit_polygons, 'sec_sidelit_polygons', self.name.get) # Join, then subtract OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***Joining polygons***") # Join toplighted polygons into a single set combined_toplit_polygons = join_polygons(toplit_polygons, 0.01, 'toplit_polygons') # Join primary sidelighted polygons into a single set combined_pri_sidelit_polygons = join_polygons(pri_sidelit_polygons, 0.01, 'pri_sidelit_polygons') # Join secondary sidelighted polygons into a single set combined_sec_sidelit_polygons = join_polygons(sec_sidelit_polygons, 0.01, 'sec_sidelit_polygons') # Join floor polygons into a single set combined_floor_polygons = join_polygons(floor_polygons, 0.01, 'floor_polygons') # Check the joined polygons check_z_zero(combined_floor_polygons, 'combined_floor_polygons', self.name.get) check_z_zero(combined_toplit_polygons, 'combined_toplit_polygons', self.name.get) check_z_zero(combined_pri_sidelit_polygons, 'combined_pri_sidelit_polygons', self.name.get) check_z_zero(combined_sec_sidelit_polygons, 'combined_sec_sidelit_polygons', self.name.get) # Make a new surface for each of the resulting polygons to visually inspect it # OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***Making Surfaces to view in SketchUp***") # combined_toplit_polygons.each do |polygon| # dummy_space = OpenStudio::Model::Space.new(model) # polygon = up_translation_top * polygon # daylt_surf = OpenStudio::Model::Surface.new(polygon, model) # daylt_surf.setConstruction(toplit_construction) # daylt_surf.setSpace(dummy_space) # daylt_surf.setName("Top") # end # combined_pri_sidelit_polygons.each do |polygon| # dummy_space = OpenStudio::Model::Space.new(model) # polygon = up_translation_pri * polygon # daylt_surf = OpenStudio::Model::Surface.new(polygon, model) # daylt_surf.setConstruction(pri_sidelit_construction) # daylt_surf.setSpace(dummy_space) # daylt_surf.setName("Pri") # end # combined_sec_sidelit_polygons.each do |polygon| # dummy_space = OpenStudio::Model::Space.new(model) # polygon = up_translation_sec * polygon # daylt_surf = OpenStudio::Model::Surface.new(polygon, model) # daylt_surf.setConstruction(sec_sidelit_construction) # daylt_surf.setSpace(dummy_space) # daylt_surf.setName("Sec") # end # combined_floor_polygons.each do |polygon| # dummy_space = OpenStudio::Model::Space.new(model) # polygon = up_translation_flr * polygon # daylt_surf = OpenStudio::Model::Surface.new(polygon, model) # daylt_surf.setConstruction(flr_construction) # daylt_surf.setSpace(dummy_space) # daylt_surf.setName("Flr") # end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***Subtracting overlapping areas***") # Subtract lower-priority daylighting areas from higher priority ones pri_minus_top_polygons = a_polygons_minus_b_polygons(combined_pri_sidelit_polygons, combined_toplit_polygons, 'combined_pri_sidelit_polygons', 'combined_toplit_polygons') sec_minus_top_polygons = a_polygons_minus_b_polygons(combined_sec_sidelit_polygons, combined_toplit_polygons, 'combined_sec_sidelit_polygons', 'combined_toplit_polygons') sec_minus_top_minus_pri_polygons = a_polygons_minus_b_polygons(sec_minus_top_polygons, combined_pri_sidelit_polygons, 'sec_minus_top_polygons', 'combined_pri_sidelit_polygons') # Check the subtracted polygons check_z_zero(pri_minus_top_polygons, 'pri_minus_top_polygons', self.name.get) check_z_zero(sec_minus_top_polygons, 'sec_minus_top_polygons', self.name.get) check_z_zero(sec_minus_top_minus_pri_polygons, 'sec_minus_top_minus_pri_polygons', self.name.get) # Make a new surface for each of the resulting polygons to visually inspect it. # First reset the z so the surfaces show up on the correct plane. if draw_daylight_areas_for_debugging combined_toplit_polygons_at_floor = polygons_set_z(combined_toplit_polygons, floor_z) pri_minus_top_polygons_at_floor = polygons_set_z(pri_minus_top_polygons, floor_z) sec_minus_top_minus_pri_polygons_at_floor = polygons_set_z(sec_minus_top_minus_pri_polygons, floor_z) combined_floor_polygons_at_floor = polygons_set_z(combined_floor_polygons, floor_z) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***Making Surfaces to view in SketchUp***") dummy_space = OpenStudio::Model::Space.new(model) combined_toplit_polygons_at_floor.each do |polygon| polygon = up_translation_top * polygon polygon = @space_transformation * polygon daylt_surf = OpenStudio::Model::Surface.new(polygon, model) daylt_surf.setConstruction(toplit_construction) daylt_surf.setSpace(dummy_space) daylt_surf.setName("Top") end pri_minus_top_polygons_at_floor.each do |polygon| polygon = up_translation_pri * polygon polygon = @space_transformation * polygon daylt_surf = OpenStudio::Model::Surface.new(polygon, model) daylt_surf.setConstruction(pri_sidelit_construction) daylt_surf.setSpace(dummy_space) daylt_surf.setName("Pri") end sec_minus_top_minus_pri_polygons_at_floor.each do |polygon| polygon = up_translation_sec * polygon polygon = @space_transformation * polygon daylt_surf = OpenStudio::Model::Surface.new(polygon, model) daylt_surf.setConstruction(sec_sidelit_construction) daylt_surf.setSpace(dummy_space) daylt_surf.setName("Sec") end combined_floor_polygons_at_floor.each do |polygon| polygon = up_translation_flr * polygon polygon = @space_transformation * polygon daylt_surf = OpenStudio::Model::Surface.new(polygon, model) daylt_surf.setConstruction(flr_construction) daylt_surf.setSpace(dummy_space) daylt_surf.setName("Flr") end end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***Calculating Daylighted Areas***") # Get the total floor area total_floor_area_m2 = total_area_of_polygons(combined_floor_polygons) total_floor_area_ft2 = OpenStudio.convert(total_floor_area_m2, 'm^2', 'ft^2').get OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "total_floor_area_ft2 = #{total_floor_area_ft2.round(1)}") # Toplighted area toplighted_area_m2 = area_a_polygons_overlap_b_polygons(combined_toplit_polygons, combined_floor_polygons, 'combined_toplit_polygons', 'combined_floor_polygons') # Primary sidelighted area primary_sidelighted_area_m2 = area_a_polygons_overlap_b_polygons(pri_minus_top_polygons, combined_floor_polygons, 'pri_minus_top_polygons', 'combined_floor_polygons') # Secondary sidelighted area secondary_sidelighted_area_m2 = area_a_polygons_overlap_b_polygons(sec_minus_top_minus_pri_polygons, combined_floor_polygons, 'sec_minus_top_minus_pri_polygons', 'combined_floor_polygons') # Convert to IP for displaying toplighted_area_ft2 = OpenStudio.convert(toplighted_area_m2, 'm^2', 'ft^2').get primary_sidelighted_area_ft2 = OpenStudio.convert(primary_sidelighted_area_m2, 'm^2', 'ft^2').get secondary_sidelighted_area_ft2 = OpenStudio.convert(secondary_sidelighted_area_m2, 'm^2', 'ft^2').get OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "toplighted_area_ft2 = #{toplighted_area_ft2.round(1)}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "primary_sidelighted_area_ft2 = #{primary_sidelighted_area_ft2.round(1)}") OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "secondary_sidelighted_area_ft2 = #{secondary_sidelighted_area_ft2.round(1)}") result['toplighted_area'] = toplighted_area_m2 result['primary_sidelighted_area'] = primary_sidelighted_area_m2 result['secondary_sidelighted_area'] = secondary_sidelighted_area_m2 result['total_window_area'] = total_window_area result['total_skylight_area'] = total_skylight_area return result end |
#exterior_wall_and_window_area ⇒ Double
Calculate the area of the exterior walls, including the area of the windows on these walls.
2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 2163 def exterior_wall_and_window_area() area_m2 = 0.0 # Loop through all surfaces in this space self.surfaces.sort.each do |surface| # Skip non-outdoor surfaces next unless surface.outsideBoundaryCondition == 'Outdoors' # Skip non-walls next unless surface.surfaceType == 'Wall' # This surface area_m2 += surface.netArea # Subsurfaces in this surface surface.subSurfaces.sort.each do |subsurface| area_m2 += subsurface.netArea end end return area_m2 end |
#find_duplicate_vertices(ruby_polygon, tol = 0.001) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A method to returns the number of duplicate vertices in a polygon. TODO does not actually wor
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 92 def find_duplicate_vertices(ruby_polygon, tol = 0.001) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "***") duplicates = [] combos = ruby_polygon.combination(2).to_a OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "########{combos.size}") combos.each do |i, j| i_vertex = OpenStudio::Point3d.new(i[0], i[1], i[2]) j_vertex = OpenStudio::Point3d.new(j[0], j[1], j[2]) distance = OpenStudio.getDistance(i_vertex, j_vertex) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "------- #{i.to_s} to #{j.to_s} = #{distance}") if distance < tol duplicates << i end end return duplicates end |
#is_plenum ⇒ Object
Determine if the space is a plenum. Assume it is a plenum if it is a supply or return plenum for an AirLoop, or if it is not part of the total floor area.
return [Bool] returns true if plenum, false if not
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 2191 def is_plenum plenum_status = false # Check if it is part of a zone # that is a supply/return plenum zone = self.thermalZone if zone.is_initialized if zone.get.isPlenum plenum_status = true end end # Check if it is designated # as not part of the building # floor area. # todo - update to check if it has internal loads unless self.partofTotalFloorArea plenum_status = true end return plenum_status end |
#is_residential(standard) ⇒ Object
Determine if the space is residential based on the space type properties for the space. For spaces with no space type, assume nonresidential.
return [Bool] true if residential, false if nonresidential
2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 2221 def is_residential(standard) is_res = false space_type = self.spaceType if space_type.is_initialized space_type = space_type.get # Get the space type data space_type_properties = space_type.get_standards_data(standard) if space_type_properties.nil? OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Could not find space type properties for #{self.name}, assuming nonresidential.") is_res = false else if space_type_properties['is_residential'] == "Yes" is_res = true else is_res = false end end else OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Space', "Could not find a space type for #{self.name}, assuming nonresidential.") is_res = false end return is_res end |
#join_polygons(polygons, tol, name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Wrapper to catch errors in joinAll method
- utilities.geometry.joinAll
-
<1> Expected polygons to join together
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 239 def join_polygons(polygons, tol, name) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "Joining #{name} from #{self.name}") combined_polygons = [] # Don't try to combine an empty array of polygons if polygons.size == 0 OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---#{name} contains no polygons, not combining.") return combined_polygons end # Open a log msg_log = OpenStudio::StringStreamLogSink.new msg_log.setLogLevel(OpenStudio::Info) # Combine the polygons combined_polygons = OpenStudio.joinAll(polygons, 0.01) # Count logged errors join_errs = 0 inner_loop_errs = 0 msg_log.logMessages.each do |msg| if /utilities.geometry/.match(msg.logChannel) if msg.logMessage.include?("Expected polygons to join together") join_errs += 1 elsif msg.logMessage.include?("Union has inner loops") inner_loop_errs += 1 end end end # TODO remove this workaround, which is tried if there # are any join errors. This handles the case of polygons # that make an inner loop, the most common case being # when all 4 sides of a space have windows. # If an error occurs, attempt to join n-1 polygons, # then subtract the if join_errs > 0 || inner_loop_errs > 0 # Open a log msg_log_2 = OpenStudio::StringStreamLogSink.new msg_log_2.setLogLevel(OpenStudio::Info) first_polygon = polygons.first polygons = polygons.drop(1) combined_polygons_2 = OpenStudio.joinAll(polygons, 0.01) join_errs_2 = 0 inner_loop_errs_2 = 0 msg_log_2.logMessages.each do |msg| if /utilities.geometry/.match(msg.logChannel) if msg.logMessage.include?("Expected polygons to join together") join_errs_2 += 1 elsif msg.logMessage.include?("Union has inner loops") inner_loop_errs_2 += 1 end end end if join_errs_2 > 0 || inner_loop_errs_2 > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, the workaround for joining polygons failed.") else # First polygon minus the already combined polygons first_polygon_minus_combined = a_polygons_minus_b_polygons([first_polygon], combined_polygons_2, 'first_polygon', 'combined_polygons_2') # Add the result back combined_polygons_2 += first_polygon_minus_combined combined_polygons = combined_polygons_2 join_errs = 0 inner_loop_errs = 0 end end # Report logged errors to user if join_errs > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, #{join_errs} of #{polygons.size} #{name} were not joined properly due to limitations of the geometry calculation methods. The resulting daylighted areas will be smaller than they should be.") end if inner_loop_errs > 0 OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, #{inner_loop_errs} of #{polygons.size} #{name} were not joined properly becasue the joined polygons have an internal hole. The resulting daylighted areas will be smaller than they should be.") end OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "---Joined #{polygons.size} #{name} into #{combined_polygons.size} polygons.") return combined_polygons end |
#polygons_set_z(polygons, new_z) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A method to zero-out the z vertex of an array of polygons
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 70 def polygons_set_z(polygons, new_z) OpenStudio::logFree(OpenStudio::Debug, "openstudio.model.Space", "### #{polygons}") # Convert the final polygons back to OpenStudio new_polygons = [] polygons.each do |polygon| new_polygon = [] polygon.each do |vertex| new_vertex = OpenStudio::Point3d.new(vertex.x, vertex.y, new_z) # Set z to hard-zero instead of vertex[2] new_polygon << new_vertex end new_polygons << new_polygon end return new_polygons end |
#ruby_polygons_to_point3d_z_zero(ruby_polygons) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A method to convert an array of arrays to an array of OpenStudio::Point3ds.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 51 def ruby_polygons_to_point3d_z_zero(ruby_polygons) # Convert the final polygons back to OpenStudio os_polygons = [] ruby_polygons.each do |ruby_polygon| os_polygon = [] ruby_polygon.each do |vertex| vertex = OpenStudio::Point3d.new(vertex[0], vertex[1], 0.0) # Set z to hard-zero instead of vertex[2] os_polygon << vertex end os_polygons << os_polygon end return os_polygons end |
#set_infiltration_rate(template) ⇒ Double
handle doors and vestibules
Set the infiltration rate for this space to include the impact of air leakage requirements in the standard.
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1996 def set_infiltration_rate(template) # Define the total building baseline infiltration rate basic_infil_rate_cfm_per_ft2 = nil infil_type = nil case template when 'DOE Ref Pre-1980', 'DOE Ref 1980-2004' OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "For #{template}, infiltration rates are not defined using this method, no changes have been made to the model.") return true when '90.1-2004', '90.1-2007' basic_infil_rate_cfm_per_ft2 = 1.8 when '90.1-2010', '90.1-2013' basic_infil_rate_cfm_per_ft2 = 1.0 end # Conversion factor # 1 m^3/s*m^2 = 196.85 cfm/ft2 conv_fact = 196.85 # Adjust the infiltration rate to the average pressure # for the prototype buildings. adj_infil_rate_cfm_per_ft2 = adjust_infiltration_to_prototype_building_conditions(basic_infil_rate_cfm_per_ft2) adj_infil_rate_m3_per_s_per_m2 = adj_infil_rate_cfm_per_ft2 / conv_fact #OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}, infil = #{adj_infil_rate_cfm_per_ft2.round(8)} cfm/ft2.") #OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}, infil = #{adj_infil_rate_m3_per_s_per_m2.round(8)} m^3/s*m^2.") # Get the exterior wall area exterior_wall_and_window_area_m2 = self.exterior_wall_and_window_area # Don't create an object if there is no exterior wall area if exterior_wall_and_window_area_m2 <= 0.0 OpenStudio::logFree(OpenStudio::Info, "openstudio.Standards.Model", "For #{template}, no exterior wall area was found, no infiltration will be added.") return true end # Calculate the total infiltration, assuming # that it only occurs through exterior walls tot_infil_m3_per_s = adj_infil_rate_m3_per_s_per_m2 * exterior_wall_and_window_area_m2 # Now spread the total infiltration rate over all # exterior surface area (for the E+ input field) all_ext_infil_m3_per_s_per_m2 = tot_infil_m3_per_s / self.exteriorArea OpenStudio::logFree(OpenStudio::Debug, "openstudio.Standards.Space", "For #{self.name}, adj infil = #{all_ext_infil_m3_per_s_per_m2.round(8)} m^3/s*m^2.") # Get any infiltration schedule already assigned to this space or its space type # If not, the always on schedule will be applied. infil_sch = nil if self.spaceInfiltrationDesignFlowRates.size > 0 old_infil = self.spaceInfiltrationDesignFlowRates[0] if old_infil.schedule.is_initialized infil_sch = old_infil.schedule.get end end if infil_sch.nil? && self.spaceType.is_initialized space_type = self.spaceType.get if space_type.spaceInfiltrationDesignFlowRates.size > 0 old_infil = space_type.spaceInfiltrationDesignFlowRates[0] if old_infil.schedule.is_initialized infil_sch = old_infil.schedule.get end end end if infil_sch.nil? infil_sch = self.model.alwaysOnDiscreteSchedule end # Create an infiltration rate object for this space infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(self.model) infiltration.setName("#{self.name} Infiltration") #infiltration.setFlowperExteriorWallArea(adj_infil_rate_m3_per_s_per_m2) infiltration.setFlowperExteriorSurfaceArea(all_ext_infil_m3_per_s_per_m2) infiltration.setSchedule(infil_sch) infiltration.setConstantTermCoefficient(0.0) infiltration.setTemperatureTermCoefficient (0.0) infiltration.setVelocityTermCoefficient(0.224) infiltration.setVelocitySquaredTermCoefficient(0.0) infiltration.setSpace(self) return true end |
#sidelightingEffectiveAperture(primary_sidelighted_area) ⇒ Double
Returns the sidelighting effective aperture sidelighting_effective_aperture = E(window area * window VT) / primary_sidelighted_area
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 983 def sidelightingEffectiveAperture(primary_sidelighted_area) # sidelighting_effective_aperture = E(window area * window VT) / primary_sidelighted_area sidelighting_effective_aperture = 9999 num_sub_surfaces = 0 # Loop through all windows and add up area * VT sum_window_area_times_vt = 0 construction_name_to_vt_map = {} self.surfaces.sort.each do |surface| next unless surface.outsideBoundaryCondition == "Outdoors" && surface.surfaceType == "Wall" surface.subSurfaces.sort.each do |sub_surface| next unless sub_surface.outsideBoundaryCondition == "Outdoors" && (sub_surface.subSurfaceType == "FixedWindow" || sub_surface.subSurfaceType == "OperableWindow") num_sub_surfaces += 1 # Get the area area_m2 = sub_surface.netArea # Get the window construction name construction_name = nil construction = sub_surface.construction if construction.is_initialized construction_name = construction.get.name.get.upcase else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, could not determine construction for #{sub_surface.name}, will not be included in sidelightingEffectiveAperture calculation.") next end # Store VT for this construction in map if not already looked up if construction_name_to_vt_map[construction_name].nil? sql = self.model.sqlFile if sql.is_initialized sql = sql.get row_query = "SELECT RowName FROM tabulardatawithstrings WHERE ReportName='EnvelopeSummary' AND ReportForString='Entire Facility' AND TableName='Exterior Fenestration' AND Value='#{construction_name.upcase}'" row_id = sql.execAndReturnFirstString(row_query) if row_id.is_initialized row_id = row_id.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Model", "VT row ID not found for construction: #{construction_name}, #{sub_surface.name} will not be included in sidelightingEffectiveAperture calculation.") row_id = 9999 end vt_query = "SELECT Value FROM tabulardatawithstrings WHERE ReportName='EnvelopeSummary' AND ReportForString='Entire Facility' AND TableName='Exterior Fenestration' AND ColumnName='Glass Visible Transmittance' AND RowName='#{row_id}'" vt = sql.execAndReturnFirstDouble(vt_query) if vt.is_initialized vt = vt.get else vt = nil end # Record the VT construction_name_to_vt_map[construction_name] = vt else OpenStudio::logFree(OpenStudio::Error, 'openstudio.standards.Space', 'Model has no sql file containing results, cannot lookup data.') end end # Get the VT from the map vt = construction_name_to_vt_map[construction_name] if vt.nil? OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, could not determine VLT for #{construction_name}, will not be included in sidelighting effective aperture caluclation.") vt = 0 end sum_window_area_times_vt += area_m2 * vt end end # Calculate the effective aperture if sum_window_area_times_vt == 0 sidelighting_effective_aperture = 9999 if num_sub_surfaces > 0 OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{self.name} has no windows where VLT could be determined, sidelighting effective aperture will be higher than it should.") end else sidelighting_effective_aperture = sum_window_area_times_vt/primary_sidelighted_area end OpenStudio::logFree(OpenStudio::Debug, 'openstudio.standards.Space', "For #{self.name} sidelighting effective aperture = #{sidelighting_effective_aperture.round(4)}.") return sidelighting_effective_aperture end |
#skylightEffectiveAperture(toplighted_area) ⇒ Double
Returns the skylight effective aperture skylight_effective_aperture = E(0.85 * skylight area * skylight VT * WF) / toplighted_area
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 1095 def skylightEffectiveAperture(toplighted_area) # skylight_effective_aperture = E(0.85 * skylight area * skylight VT * WF) / toplighted_area skylight_effective_aperture = 0.0 num_sub_surfaces = 0 # Assume that well factor (WF) is 0.9 (all wells are less than 2 feet deep) OpenStudio::logFree(OpenStudio::Info, "openstudio.model.Space", "Assuming that all skylight wells are less than 2 feet deep to calculate skylight effective aperture.") wf = 0.9 # Loop through all windows and add up area * VT sum_85pct_times_skylight_area_times_vt_times_wf = 0 construction_name_to_vt_map = {} self.surfaces.sort.each do |surface| next unless surface.outsideBoundaryCondition == "Outdoors" && surface.surfaceType == "RoofCeiling" surface.subSurfaces.sort.each do |sub_surface| next unless sub_surface.outsideBoundaryCondition == "Outdoors" && sub_surface.subSurfaceType == "Skylight" num_sub_surfaces += 1 # Get the area area_m2 = sub_surface.netArea # Get the window construction name construction_name = nil construction = sub_surface.construction if construction.is_initialized construction_name = construction.get.name.get.upcase else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, ") next end # Store VT for this construction in map if not already looked up if construction_name_to_vt_map[construction_name].nil? sql = self.model.sqlFile if sql.is_initialized sql = sql.get row_query = "SELECT RowName FROM tabulardatawithstrings WHERE ReportName='EnvelopeSummary' AND ReportForString='Entire Facility' AND TableName='Exterior Fenestration' AND Value='#{construction_name}'" row_id = sql.execAndReturnFirstString(row_query) if row_id.is_initialized row_id = row_id.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Model", "Data not found for query: #{row_query}") next end vt_query = "SELECT Value FROM tabulardatawithstrings WHERE ReportName='EnvelopeSummary' AND ReportForString='Entire Facility' AND TableName='Exterior Fenestration' AND ColumnName='Glass Visible Transmittance' AND RowName='#{row_id}'" vt = sql.execAndReturnFirstDouble(vt_query) if vt.is_initialized vt = vt.get else vt = nil end # Record the VT construction_name_to_vt_map[construction_name] = vt else OpenStudio::logFree(OpenStudio::Error, 'openstudio.model.Model', 'Model has no sql file containing results, cannot lookup data.') end end # Get the VT from the map vt = construction_name_to_vt_map[construction_name] if vt.nil? OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "For #{self.name}, could not determine VLT for #{construction_name}, will not be included in skylight effective aperture caluclation.") vt = 0 end sum_85pct_times_skylight_area_times_vt_times_wf += 0.85 * area_m2 * vt * wf end end # Calculate the effective aperture if sum_85pct_times_skylight_area_times_vt_times_wf == 0 skylight_effective_aperture = 9999 if num_sub_surfaces > 0 OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Space', "#{self.name} has no skylights where VLT could be determined, skylight effective aperture will be higher than it should.") end else skylight_effective_aperture = sum_85pct_times_skylight_area_times_vt_times_wf/toplighted_area end OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Space', "#{self.name} skylight effective aperture = #{skylight_effective_aperture}.") return skylight_effective_aperture end |
#total_area_of_polygons(polygons) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Gets the total area of a series of polygons
332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/openstudio-standards/standards/Standards.Space.rb', line 332 def total_area_of_polygons(polygons) total_area_m2 = 0 polygons.each do |polygon| area_m2 = OpenStudio.getArea(polygon) if area_m2.is_initialized total_area_m2 += area_m2.get else OpenStudio::logFree(OpenStudio::Warn, "openstudio.model.Space", "Could not get area for a polygon in #{self.name}, daylighted area calculation will not be accurate.") end end return total_area_m2 end |