-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(room): Finish adding RoomDoe2Properties to assign HVAC parameters
- Loading branch information
1 parent
4101ae0
commit a3f15e3
Showing
6 changed files
with
357 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# coding=utf-8 | ||
"""Model DOE-2 Properties.""" | ||
|
||
|
||
class ModelDoe2Properties(object): | ||
"""DOE-2 Properties for Honeybee Model. | ||
Args: | ||
host: A honeybee_core Model object that hosts these properties. | ||
Properties: | ||
* host | ||
""" | ||
|
||
def __init__(self, host): | ||
"""Initialize ModelDoe2Properties.""" | ||
self._host = host | ||
|
||
@property | ||
def host(self): | ||
"""Get the Model object hosting these properties.""" | ||
return self._host | ||
|
||
def to_dict(self): | ||
"""Return Model DOE-2 properties as a dictionary.""" | ||
return {'doe2': {'type': 'ModelDoe2Properties'}} | ||
|
||
def apply_properties_from_dict(self, data): | ||
"""Apply the energy properties of a dictionary to the host Model of this object. | ||
Args: | ||
data: A dictionary representation of an entire honeybee-core Model. | ||
Note that this dictionary must have ModelEnergyProperties in order | ||
for this method to successfully apply the energy properties. | ||
""" | ||
assert 'doe2' in data['properties'], \ | ||
'Dictionary possesses no ModelDoe2Properties.' | ||
room_doe2_dicts = [] | ||
for room_dict in data['rooms']: | ||
try: | ||
room_doe2_dicts.append(room_dict['properties']['doe2']) | ||
except KeyError: | ||
room_doe2_dicts.append(None) | ||
for room, r_dict in zip(self.host.rooms, room_doe2_dicts): | ||
if r_dict is not None: | ||
room.properties.doe2.apply_properties_from_dict(r_dict) | ||
|
||
def ToString(self): | ||
return self.__repr__() | ||
|
||
def __repr__(self): | ||
return 'Model DOE2 Properties: [host: {}]'.format(self.host.display_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Tests the features that honeybee_doe2 adds to honeybee_core Model.""" | ||
from honeybee.room import Room | ||
from honeybee.model import Model | ||
from honeybee_energy.lib.programtypes import office_program | ||
|
||
|
||
def test_from_dict(): | ||
"""Test the Room from_dict method with doe2 properties.""" | ||
room = Room.from_box('ShoeBox', 5, 10, 3) | ||
room.properties.energy.program_type = office_program | ||
room.properties.energy.add_default_ideal_air() | ||
south_face = room[3] | ||
south_face.apertures_by_ratio(0.4, 0.01) | ||
south_face.apertures[0].overhang(0.5, indoor=False) | ||
south_face.apertures[0].overhang(0.5, indoor=True) | ||
|
||
room.properties.doe2.assigned_flow = 100 | ||
room.properties.doe2.flow_per_area = 1 | ||
room.properties.doe2.min_flow_ratio = 0.3 | ||
room.properties.doe2.min_flow_per_area = 0.35 | ||
room.properties.doe2.hmax_flow_ratio = 0.5 | ||
|
||
model = Model('Tiny_House', [room]) | ||
|
||
|
||
model_dict = model.to_dict() | ||
new_model = Model.from_dict(model_dict) | ||
assert new_model.to_dict() == model_dict | ||
|
||
new_room = new_model.rooms[0] | ||
assert new_room.properties.doe2.assigned_flow == 100 | ||
assert new_room.properties.doe2.flow_per_area == 1 | ||
assert new_room.properties.doe2.min_flow_ratio == 0.3 | ||
assert new_room.properties.doe2.min_flow_per_area == 0.35 | ||
assert new_room.properties.doe2.hmax_flow_ratio == 0.5 |
Oops, something went wrong.