Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions src/osut/osut.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,18 +1656,28 @@ def scheduleIntervalMinMax(sched=None) -> dict:
- "min" (float): min temperature. (None if invalid inputs - see logs).
- "max" (float): max temperature. (None if invalid inputs - see logs).
"""
mth = "osut.scheduleCompactMinMax"
mth = "osut.scheduleIntervalMinMax"
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

cl = openstudio.model.ScheduleInterval
vals = []
res = dict(min=None, max=None)

if not isinstance(sched, cl):
return oslg.mismatch("sched", sched, cl, mth, CN.DBG, res)

vals = sched.timeSeries().values()
values = sched.timeSeries().values()
length = len(values)

res["min"] = min(values)
res["max"] = max(values)
for i in range(length):
try:
value = float(values[i])
value = vals.append(value)
except:
oslg.invalid("numerical at %d" % i, mth, 1, CN.ERR)

if not vals: return res

res["min"] = min(vals)
res["max"] = max(vals)

try:
res["min"] = float(res["min"])
Expand Down Expand Up @@ -2601,6 +2611,17 @@ def availabilitySchedule(model=None, avl=""):

return schedule

# ---- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---- #
# This final set of utilities targets OpenStudio geometry. Many of the
# following geometry methods rely on Boost as an OpenStudio dependency.
# As per Boost requirements, points (e.g. vertical polygon) must be 'aligned':
# - first rotated/tilted as to lay flat along XY plane (Z-axis ~= 0)
# - initial Z-axis values now become Y-axis values
# - points with the lowest X-axis values are 'aligned' along X-axis (0)
# - points with the lowest Z-axis values are 'aligned' along Y-axis (0)
# - for several Boost methods, points must be clockwise in sequence
#
# Check OSut's poly() method, which offers such Boost-related options.

def transforms(group=None) -> dict:
""""Returns OpenStudio site/space transformation & rotation angle.
Expand Down Expand Up @@ -2704,7 +2725,7 @@ def p3Dv(pts=None) -> openstudio.Point3dVector:
pts (list): OpenStudio 3D points.

Returns:
openstudio.Point3dVector: Vector of 3D points (see logs if empty).
openstudio.Point3dVector: Vector of 3D points (see 'p3Dv' logs if empty).

"""
mth = "osut.p3Dv"
Expand Down Expand Up @@ -6085,7 +6106,7 @@ def genSlab(pltz=[], z=0) -> openstudio.Point3dVector:
slb = vtx

# Once joined, re-adjust Z-axis coordinates.
if abs(z) > CN.TOL:
if round(z, 2) != 0.00:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More appropriate.

vtx = openstudio.Point3dVector()

for pt in slb: vtx.append(openstudio.Point3d(pt.x(), pt.y(), z))
Expand Down
38 changes: 28 additions & 10 deletions tests/test_osut.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def test05_construction_generation(self):
self.assertEqual(o.status(), 0)
del model

# Insulated (conditioned), parking garage roof (polyiso under 8" slab).
# Roof above conditioned parking garage (polyiso under 8" slab).
specs = dict(type="roof", uo=0.214, clad="heavy", frame="medium", finish="none")
model = openstudio.model.Model()
c = osut.genConstruction(model, specs)
Expand Down Expand Up @@ -1731,9 +1731,27 @@ def test17_minmax_heatcool_setpoints(self):
self.assertTrue(cc.setTemperatureCalculationRequestedAfterLayerNumber(1))
self.assertTrue(floor.setConstruction(cc))

# Test 'fixed interval' schedule. Annual time series - no variation.
start = model.getYearDescription().makeDate(1, 1)
inter = openstudio.Time(0, 1, 0, 0)
values = openstudio.createVector([22.78] * 8760)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSut enabled ScheduleFixedInterval checks, e.g.:

  • min/max setpoint temperatures
  • is space UNCONDITIONED, etc.

Yet no unit test had been in place.

series = openstudio.TimeSeries(start, inter, values, "")
limits = openstudio.model.ScheduleTypeLimits(model)
limits.setName("Radiant Electric Heating Setpoint Schedule Type Limits")
self.assertTrue(limits.setNumericType("Continuous"))
self.assertTrue(limits.setUnitType("Temperature"))

schedule = openstudio.model.ScheduleFixedInterval(model)
schedule.setName("Radiant Electric Heating Setpoint Schedule")
self.assertTrue(schedule.setTimeSeries(series))
self.assertTrue(schedule.setTranslatetoScheduleFile(False))
self.assertTrue(schedule.setScheduleTypeLimits(limits))

tvals = schedule.timeSeries().values()
self.assertTrue(isinstance(tvals, openstudio.Vector))
for i in range(len(tvals)): self.assertTrue(isinstance(tvals[i], float))

availability = osut.availabilitySchedule(model)
schedule = openstudio.model.ScheduleConstant(model)
self.assertTrue(schedule.setValue(22.78)) # reuse cooling setpoint

# Create radiant electric heating.
ht = (openstudio.model.ZoneHVACLowTemperatureRadiantElectric(
Expand Down Expand Up @@ -5384,15 +5402,15 @@ def test35_facet_retrieval(self):

translator = openstudio.osversion.VersionTranslator()

path = openstudio.path("./tests/files/osms/out/seb2.osm")
path = openstudio.path("./tests/files/osms/out/seb_ext2.osm")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harmonizing with Ruby test.

model = translator.loadModel(path)
self.assertTrue(model)
model = model.get()
spaces = model.getSpaces()
surfs = model.getSurfaces()
subs = model.getSubSurfaces()
self.assertEqual(len(surfs), 56)
self.assertEqual(len(subs), 8)
self.assertEqual(len(surfs), 59)
self.assertEqual(len(subs), 14)

# The solution is similar to:
# OpenStudio::Model::Space::findSurfaces(minDegreesFromNorth,
Expand All @@ -5416,15 +5434,15 @@ def test35_facet_retrieval(self):
roofs1 = osut.facets(spaces, "Outdoors", "RoofCeiling", "top")
roofs2 = osut.facets(spaces, "Outdoors", "RoofCeiling", "foo")

self.assertEqual(len(windows), 8)
self.assertEqual(len(skylights), 0)
self.assertEqual(len(walls), 26)
self.assertEqual(len(windows), 11)
self.assertEqual(len(skylights), 3)
self.assertEqual(len(walls), 28)
self.assertFalse(northsouth)
self.assertEqual(len(northeast), 8)
self.assertEqual(len(north), 14)
self.assertEqual(len(floors1a), 4)
self.assertEqual(len(floors1b), 4)
self.assertEqual(len(roofs1), 4)
self.assertEqual(len(roofs1), 5)
self.assertFalse(roofs2)

# Concise variants, same output. In the SEB model, floors face "Ground".
Expand Down