Esempio n. 1
0
def test_move():
    """Test the Room move method."""
    room = Room.from_box('ShoeBoxZone', 2, 2, 2)

    vec_1 = Vector3D(2, 2, 2)
    new_room = room.duplicate()
    new_room.move(vec_1)
    assert new_room.geometry.vertices[0] == Point3D(2, 2, 2)
    assert new_room.geometry.vertices[1] == Point3D(2, 4, 2)
    assert new_room.geometry.vertices[2] == Point3D(4, 4, 2)
    assert new_room.geometry.vertices[3] == Point3D(4, 2, 2)

    assert room.floor_area == new_room.floor_area
    assert room.volume == new_room.volume
Esempio n. 2
0
def test_to_dict():
    """Test the Room to_dict method."""
    room = Room.from_box('Shoe Box Zone', 5, 10, 3)

    rd = room.to_dict()
    assert rd['type'] == 'Room'
    assert rd['name'] == 'ShoeBoxZone'
    assert rd['display_name'] == 'Shoe Box Zone'
    assert 'faces' in rd
    assert len(rd['faces']) == 6
    assert 'indoor_shades' not in rd
    assert 'outdoor_shades' not in rd
    assert 'properties' in rd
    assert rd['properties']['type'] == 'RoomProperties'
Esempio n. 3
0
def test_solve_adjacency_aperture():
    """Test the solve adjacency method with an interior aperture."""
    room_south = Room.from_box('South Zone', 5, 5, 3, origin=Point3D(0, 0, 0))
    room_north = Room.from_box('North Zone', 5, 5, 3, origin=Point3D(0, 5, 0))
    room_south[1].apertures_by_ratio(0.4, 0.01)
    room_north[3].apertures_by_ratio(0.4, 0.01)

    assert room_south[1].apertures[
        0].boundary_condition == boundary_conditions.outdoors
    assert room_north[3].apertures[
        0].boundary_condition == boundary_conditions.outdoors

    adj_info = Room.solve_adjacency([room_south, room_north], 0.01)

    assert isinstance(room_south[1].apertures[0].boundary_condition, Surface)
    assert isinstance(room_north[3].apertures[0].boundary_condition, Surface)
    assert room_south[1].apertures[0].boundary_condition.boundary_condition_object == \
        room_north[3].apertures[0].name
    assert room_north[3].apertures[0].boundary_condition.boundary_condition_object == \
        room_south[1].apertures[0].name
    assert len(adj_info['adjacent_faces']) == 1
    assert len(adj_info['adjacent_apertures']) == 1
    assert len(adj_info['adjacent_doors']) == 0
Esempio n. 4
0
def test_make_plenum():
    """Test the make_plenum method."""
    room = Room.from_box('ShoeBox', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    assert room.properties.energy.people is not None
    assert room.properties.energy.infiltration is not None
    assert room.properties.energy.is_conditioned

    room.properties.energy.make_plenum()
    assert room.properties.energy.people is None
    assert room.properties.energy.infiltration is not None
    assert not room.properties.energy.is_conditioned
def test_check_missing_adjacencies():
    """Test the check_missing_adjacencies method."""
    room_south = Room.from_box('SouthZone', 5, 5, 3, origin=Point3D(0, 0, 0))
    room_north = Room.from_box('NorthZone', 5, 5, 3, origin=Point3D(0, 5, 0))
    room_south[1].apertures_by_ratio(0.4, 0.01)
    room_south[3].apertures_by_ratio(0.4, 0.01)
    room_north[3].apertures_by_ratio(0.4, 0.01)
    Room.solve_adjacency([room_south, room_north], 0.01)

    model_1 = Model('SouthHouse', [room_south])
    model_2 = Model('NorthHouse', [room_north])

    assert len(model_1.rooms) == 1
    assert len(model_1.faces) == 6
    assert len(model_1.apertures) == 2
    with pytest.raises(ValueError):
        model_1.check_missing_adjacencies()

    model_1.add_model(model_2)
    assert len(model_1.rooms) == 2
    assert len(model_1.faces) == 12
    assert len(model_1.apertures) == 3
    assert model_1.check_missing_adjacencies()
def test_convert_to_units():
    """Test the Model convert_to_units method."""
    room = Room.from_box('TinyHouseZone', 120, 240, 96)
    inches_conversion = Model.conversion_factor_to_meters('Inches')

    model = Model('TinyHouse', [room], units='Inches')
    model.convert_to_units('Meters')

    assert room.floor_area == pytest.approx(120 * 240 * (inches_conversion**2),
                                            rel=1e-3)
    assert room.volume == pytest.approx(120 * 240 * 96 *
                                        (inches_conversion**3),
                                        rel=1e-3)
    assert model.units == 'Meters'
Esempio n. 7
0
def test_apertures_by_identifier():
    """Test the apertures_by_identifier method."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    model = Model('TinyHouse', [room])

    assert len(model.apertures_by_identifier(['TinyHouseZone_Back_Glz0'])) == 1
    with pytest.raises(ValueError):
        model.apertures_by_identifier(['NotAnAperture'])

    model.remove_assigned_apertures()
    with pytest.raises(ValueError):
        model.shades_by_identifier(['TinyHouseZone_Back_Glz0'])
def test_color_room():
    """Test ColorRoom."""
    room_south = Room.from_box('SouthZone', 5, 5, 3, origin=Point3D(0, 0, 0))
    room_north = Room.from_box('NorthZone', 5, 5, 3, origin=Point3D(0, 5, 0))
    room_south[1].apertures_by_ratio(0.4, 0.01)
    room_north[3].apertures_by_ratio(0.4, 0.01)

    room_south[3].apertures_by_ratio(0.4, 0.01)
    room_south[3].apertures[0].overhang(0.5, indoor=False)
    room_south[3].apertures[0].overhang(0.5, indoor=True)
    room_south[3].apertures[0].move_shades(Vector3D(0, 0, -0.5))
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    door = Door('FrontDoor', Face3D(door_verts))
    room_north[1].add_door(door)
    aperture = Aperture('FrontAperture', Face3D(aperture_verts))
    room_north[1].add_aperture(aperture)
    Room.solve_adjacency([room_south, room_north], 0.01)

    color_room1 = ColorRoom([room_south, room_north], 'display_name')
    color_room2 = ColorRoom([room_south, room_north], 'multiplier')
    
    assert len(color_room1.rooms) == len(color_room2.rooms) == 2
    assert color_room1.attr_name == color_room1.attr_name_end == 'display_name'
    assert color_room2.attr_name == color_room2.attr_name_end == 'multiplier'
    assert color_room1.attributes == ('SouthZone', 'NorthZone')
    assert color_room2.attributes == ('1', '1')
    assert isinstance(color_room1.graphic_container, GraphicContainer)
    assert len(color_room1.attributes_unique) == \
        len(color_room1.graphic_container.legend.segment_colors) == 2
    assert len(color_room2.attributes_unique) == \
        len(color_room2.graphic_container.legend.segment_colors) == 1
    assert len(color_room1.floor_faces) == len(color_room2.floor_faces) == 2
    assert isinstance(color_room1.min_point, Point3D)
    assert isinstance(color_room1.max_point, Point3D)
Esempio n. 9
0
def test_to_from_dict_methods():
    """Test the to/from dict methods."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    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)
    south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5))
    north_face = room[1]
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    aperture_verts = [
        Point3D(4.5, 10, 1),
        Point3D(2.5, 10, 1),
        Point3D(2.5, 10, 2.5),
        Point3D(4.5, 10, 2.5)
    ]
    door = Door('Front Door', Face3D(door_verts))
    north_face.add_door(door)
    aperture = Aperture('Front Aperture', Face3D(aperture_verts))
    north_face.add_aperture(aperture)
    model = Model('Tiny House', [room])
    model.north_angle = 15

    model_dict = model.to_dict()
    new_model = Model.from_dict(model_dict)
    assert model_dict == new_model.to_dict()

    assert new_model.name == 'TinyHouse'
    assert new_model.display_name == 'Tiny House'
    assert new_model.north_angle == 15
    assert len(new_model.rooms) == 1
    assert isinstance(new_model.rooms[0], Room)
    assert len(new_model.faces) == 6
    assert isinstance(new_model.faces[0], Face)
    assert len(new_model.shades) == 2
    assert isinstance(new_model.shades[0], Shade)
    assert len(new_model.apertures) == 2
    assert isinstance(new_model.apertures[0], Aperture)
    assert len(new_model.doors) == 1
    assert isinstance(new_model.doors[0], Door)
    assert len(new_model.orphaned_faces) == 0
    assert len(new_model.orphaned_shades) == 0
    assert len(new_model.orphaned_apertures) == 0
    assert len(new_model.orphaned_doors) == 0
Esempio n. 10
0
def test_colorfaces_init():
    """Test the initialization of ColorFace and basic properties."""
    data = []
    identifiers = ['Bottom', 'Front', 'Right', 'Back', 'Left', 'Top']
    for identifier in identifiers:
        metadata = {
            'type': 'Surface Inside Face Temperature',
            'Surface': 'RESIDENCE_{}'.format(identifier.upper())
        }
        head = Header(Temperature(), 'C', AnalysisPeriod(1, 1, 0, 1, 1, 23),
                      metadata)
        data.append(HourlyContinuousCollection(head, [22] * 24))

    room = Room.from_box('Residence', 3, 6, 3.2)
    color_obj = ColorFace(data, room.faces)

    str(color_obj)
    assert len(color_obj.data_collections) == 6
    for coll in color_obj.data_collections:
        assert isinstance(coll, HourlyContinuousCollection)
        assert coll.header.unit == 'C'
    assert isinstance(color_obj.legend_parameters, LegendParameters)
    assert color_obj.simulation_step is None
    assert color_obj.normalize
    assert color_obj.geo_unit == 'm'
    assert len(color_obj.matched_flat_faces) == 6
    assert len(color_obj.matched_values) == 6
    for val in color_obj.matched_values:
        assert isinstance(val, (float, int))
    assert len(color_obj.matched_flat_geometry) == 6
    for face3d in color_obj.matched_flat_geometry:
        assert isinstance(face3d, Face3D)
    assert len(color_obj.matched_flat_areas) == 6
    for val in color_obj.matched_flat_areas:
        assert isinstance(val, (float, int))
    assert isinstance(color_obj.graphic_container, GraphicContainer)
    assert len(color_obj.graphic_container.value_colors) == 6
    assert color_obj.unit == 'C'
    assert isinstance(color_obj.data_type, Temperature)
    assert color_obj.data_type_text == 'Surface Inside Face Temperature'
    assert color_obj.title_text == 'Average Surface Inside Face Temperature ' \
        '(C)\n1/1 to 1/1 between 0 and 23 '

    color_obj.simulation_step = 0
    assert color_obj.title_text == 'Surface Inside Face Temperature ' \
        '(C)\n01 Jan 00:00'

    with pytest.raises(AssertionError):
        color_obj.simulation_step = 8760
Esempio n. 11
0
def test_recipe_run():
    # create a model for simulation
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    model = Model('TinyHouse', [room])

    # pass the model to the recipe
    recipe = Recipe('daylight_factor')
    recipe.input_value_by_name('model', model)
    recipe.input_value_by_name('sensor-count', 30)
    recipe.input_value_by_name('radiance-parameters', None)

    # run the recipe
    recipe.run()
Esempio n. 12
0
def test_make_ground():
    """Test the make_ground method."""
    room = Room.from_box('ShoeBox', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    assert room.properties.energy.people is not None
    assert room.properties.energy.infiltration is not None
    assert room.properties.energy.is_conditioned

    soil_constr = OpaqueConstruction('Conc_Pavement', [concrete_hw])
    room.properties.energy.make_ground(soil_constr)
    assert room.properties.energy.people is None
    assert room.properties.energy.infiltration is None
    assert not room.properties.energy.is_conditioned
Esempio n. 13
0
def test_check_duplicate_shade_names():
    """Test the check_duplicate_shade_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    room.add_indoor_shade(Shade('Table', table_geo))

    model = Model('Test House', [room])
    assert model.check_duplicate_shade_names(False)
    tree_canopy_geo = Face3D.from_regular_polygon(6, 2, Plane(o=Point3D(5, -3, 4)))
    model.add_shade(Shade('Table', tree_canopy_geo))
    assert not model.check_duplicate_shade_names(False)
    with pytest.raises(ValueError):
        model.check_duplicate_shade_names(True)
Esempio n. 14
0
def test_ground_by_custom_surface():
    """Test the ground_by_custom_surface method."""
    room = Room.from_box('ShoeBoxZone', 5, 10, 3, origin=Point3D(0, 0, 3))
    grd_face1 = Face3D([Point3D(-10, -10, 3), Point3D(-10, 10, 3),
                        Point3D(10, 10, 3), Point3D(10, -10, 3)])
    grd_face2 = Face3D([Point3D(-10, 10, 3), Point3D(10, 10, 3),
                        Point3D(10, 10, 6), Point3D(-10, 10, 6)])

    assert isinstance(room[0].boundary_condition, Outdoors)
    assert isinstance(room[1].boundary_condition, Outdoors)
    room.ground_by_custom_surface([grd_face1, grd_face2])
    assert isinstance(room[0].boundary_condition, Ground)
    assert isinstance(room[1].boundary_condition, Ground)
    for face in room[2:]:
        assert isinstance(face.boundary_condition, Outdoors)
Esempio n. 15
0
def test_writer_to_idf():
    """Test the Model to.idf method."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough',
                           0.95, 0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Thermal Mass Floor', [stone])
    room[0].properties.energy.construction = thermal_mass_constr

    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)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = ShadeConstruction('OutdoorLightShelf', 0.5, 0.5)
    light_shelf_in = ShadeConstruction('IndoorLightShelf', 0.7, 0.7)
    south_face.apertures[0].outdoor_shades[0].properties.energy.construction = light_shelf_out
    south_face.apertures[0].indoor_shades[0].properties.energy.construction = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    door = Door('FrontDoor', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    aperture = Aperture('FrontAperture', Face3D(aperture_verts))
    triple_pane = WindowConstruction(
        'Triple Pane Window', [clear_glass, air_gap, clear_glass, air_gap, clear_glass])
    aperture.properties.energy.construction = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('TreeCanopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('TinyHouse', [room], orphaned_shades=[tree_canopy])

    assert hasattr(model.to, 'idf')
    idf_string = model.to.idf(model, schedule_directory='./tests/idf/')
Esempio n. 16
0
def test_to_dict():
    """Test the Model to_dict method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    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)
    south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5))
    north_face = room[1]
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    aperture_verts = [
        Point3D(4.5, 10, 1),
        Point3D(2.5, 10, 1),
        Point3D(2.5, 10, 2.5),
        Point3D(4.5, 10, 2.5)
    ]
    door = Door('Front Door', Face3D(door_verts))
    north_face.add_door(door)
    aperture = Aperture('Front Aperture', Face3D(aperture_verts))
    north_face.add_aperture(aperture)
    model = Model('Tiny House', [room])
    model.north_angle = 15

    model_dict = model.to_dict()
    assert model_dict['type'] == 'Model'
    assert model_dict['name'] == 'TinyHouse'
    assert model_dict['display_name'] == 'Tiny House'
    assert 'rooms' in model_dict
    assert len(model_dict['rooms']) == 1
    assert 'faces' in model_dict['rooms'][0]
    assert len(model_dict['rooms'][0]['faces']) == 6
    assert 'apertures' in model_dict['rooms'][0]['faces'][3]
    assert len(model_dict['rooms'][0]['faces'][3]['apertures']) == 1
    assert 'doors' in model_dict['rooms'][0]['faces'][1]
    assert len(model_dict['rooms'][0]['faces'][1]['doors']) == 1
    assert 'outdoor_shades' in model_dict['rooms'][0]['faces'][3]['apertures'][
        0]
    assert len(model_dict['rooms'][0]['faces'][3]['apertures'][0]
               ['outdoor_shades']) == 1
    assert 'north_angle' in model_dict
    assert model_dict['north_angle'] == 15
    assert 'properties' in model_dict
    assert model_dict['properties']['type'] == 'ModelProperties'
Esempio n. 17
0
def test_to_dict():
    """Test the Room to_dict method with radiance properties."""
    custom_set = ModifierSet('Custom_Modifier_Set')
    room = Room.from_box('Shoe_Box', 5, 10, 3)

    rd = room.to_dict()
    assert 'properties' in rd
    assert rd['properties']['type'] == 'RoomProperties'
    assert 'radiance' in rd['properties']
    assert rd['properties']['radiance']['type'] == 'RoomRadianceProperties'
    assert 'modifier_set' not in rd['properties']['radiance'] or \
        rd['properties']['radiance']['modifier_set'] is None

    room.properties.radiance.modifier_set = custom_set
    rd = room.to_dict()
    assert rd['properties']['radiance']['modifier_set'] is not None
Esempio n. 18
0
def test_recipe_run():
    # create a model for simulation
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    model = Model('TinyHouse', [room])
    model.properties.radiance.sensor_grids = \
        [room.properties.radiance.generate_sensor_grid(1, offset=0.8)]

    # pass the model to the recipe
    recipe = Recipe('daylight_factor')
    recipe.input_value_by_name('model', model)
    recipe.input_value_by_name('radiance-parameters', None)

    # run the recipe
    recipe.run()
def test_default_properties():
    """Test the auto-assigning of Room properties."""
    room = Room.from_box('ShoeBox', 5, 10, 3, 90, Point3D(0, 0, 3))

    assert room.properties.energy.construction_set.identifier == \
        'Default Generic Construction Set'
    assert room.properties.energy.program_type.identifier == 'Plenum'
    assert room.properties.energy.hvac is None
    assert not room.properties.energy.is_conditioned
    assert room.properties.energy.people is None
    assert room.properties.energy.lighting is None
    assert room.properties.energy.electric_equipment is None
    assert room.properties.energy.gas_equipment is None
    assert room.properties.energy.infiltration is None
    assert room.properties.energy.ventilation is None
    assert room.properties.energy.setpoint is None
Esempio n. 20
0
def test_model_properties_setability():
    """Test the setting of properties on the Model."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)

    model = Model('TinyHouse', [room])

    model.display_name = 'TestBox'
    assert model.display_name == 'TestBox'
    model.units = 'Feet'
    assert model.units == 'Feet'
    model.tolerance = 0.01
    assert model.tolerance == 0.01
    model.angle_tolerance = 0.01
    assert model.angle_tolerance == 0.01
Esempio n. 21
0
def model_energy_no_program(directory):
    room = Room.from_box('Abandoned_Tiny_House', 5, 10, 3)

    stone = EnergyMaterial('Thick Stone', 0.3, 2.31, 2322, 832, 'Rough',
                           0.95, 0.75, 0.8)
    thermal_mass_constr = OpaqueConstruction('Thermal Mass Floor', [stone])
    room[0].properties.energy.construction = thermal_mass_constr

    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)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = ShadeConstruction('Outdoor_Light_Shelf', 0.5, 0.5)
    light_shelf_in = ShadeConstruction('Indoor_Light_Shelf', 0.7, 0.7)
    south_face.apertures[0].outdoor_shades[0].properties.energy.construction = light_shelf_out
    south_face.apertures[0].indoor_shades[0].properties.energy.construction = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    door = Door('Front_Door', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    aperture = Aperture('Front_Aperture', Face3D(aperture_verts))
    triple_pane = WindowConstruction(
        'Triple Pane Window', [clear_glass, air_gap, clear_glass, air_gap, clear_glass])
    aperture.properties.energy.construction = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree_Canopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy])
    model.north_angle = 15

    dest_file = os.path.join(directory, 'model_energy_no_program.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
Esempio n. 22
0
def test_model_init():
    """Test the initialization of the Model and basic properties."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    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)
    south_face.apertures[0].move_shades(Vector3D(0, 0, -0.5))
    north_face = room[1]
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    aperture_verts = [
        Point3D(4.5, 10, 1),
        Point3D(2.5, 10, 1),
        Point3D(2.5, 10, 2.5),
        Point3D(4.5, 10, 2.5)
    ]
    door = Door('Front Door', Face3D(door_verts))
    north_face.add_door(door)
    aperture = Aperture('Front Aperture', Face3D(aperture_verts))
    north_face.add_aperture(aperture)

    model = Model('Tiny House', [room])
    str(model)  # test the string representation of the object

    assert model.name == 'TinyHouse'
    assert model.display_name == 'Tiny House'
    assert model.north_angle == 0
    assert model.north_vector == Vector2D(0, 1)
    assert len(model.rooms) == 1
    assert isinstance(model.rooms[0], Room)
    assert len(model.faces) == 6
    assert isinstance(model.faces[0], Face)
    assert len(model.shades) == 2
    assert isinstance(model.shades[0], Shade)
    assert len(model.apertures) == 2
    assert isinstance(model.apertures[0], Aperture)
    assert len(model.doors) == 1
    assert isinstance(model.doors[0], Door)
    assert len(model.orphaned_faces) == 0
    assert len(model.orphaned_shades) == 0
    assert len(model.orphaned_apertures) == 0
    assert len(model.orphaned_doors) == 0
Esempio n. 23
0
def test_writer_to_rad():
    """Test the Model to.rad method."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)

    dark_floor = Plastic.from_single_reflectance('DarkFloor', 0.1)
    room[0].properties.radiance.modifier = dark_floor

    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)
    south_face.move_shades(Vector3D(0, 0, -0.5))
    light_shelf_out = Plastic.from_single_reflectance('outdoor_light_shelf_0.5', 0.5)
    light_shelf_in = Plastic.from_single_reflectance('indoor_light_shelf_0.70', 0.7)
    south_face.apertures[0].outdoor_shades[0].properties.radiance.modifier = light_shelf_out
    south_face.apertures[0].indoor_shades[0].properties.radiance.modifier = light_shelf_in

    north_face = room[1]
    north_face.overhang(0.25, indoor=False)
    door_verts = [Point3D(2, 10, 0.1), Point3D(1, 10, 0.1),
                  Point3D(1, 10, 2.5), Point3D(2, 10, 2.5)]
    door = Door('Front_Door', Face3D(door_verts))
    north_face.add_door(door)

    aperture_verts = [Point3D(4.5, 10, 1), Point3D(2.5, 10, 1),
                      Point3D(2.5, 10, 2.5), Point3D(4.5, 10, 2.5)]
    aperture = Aperture('Front_Aperture', Face3D(aperture_verts))
    triple_pane = Glass.from_single_transmittance('custom_triple_pane_0.3', 0.3)
    aperture.properties.radiance.modifier = triple_pane
    north_face.add_aperture(aperture)

    tree_canopy_geo = Face3D.from_regular_polygon(
        6, 2, Plane(Vector3D(0, 0, 1), Point3D(5, -3, 4)))
    tree_canopy = Shade('Tree_Canopy', tree_canopy_geo)

    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    table = Shade('Table', table_geo)
    room.add_indoor_shade(table)

    model = Model('Tiny_House', [room], orphaned_shades=[tree_canopy])

    assert hasattr(model.to, 'rad')
    rad_string = model.to.rad(model)
    assert len(rad_string) == 2
    assert 'outdoor_light_shelf_0.5' in rad_string[1]
    assert 'Front_Door' in rad_string[0]
Esempio n. 24
0
def model_energy_service_hot_water(directory):
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.program_type = prog_type_lib.office_program
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Water Use', simple_office, None,
                               schedule_types.fractional)
    shw = ServiceHotWater('Office Hot Water', 0.1, schedule)
    room.properties.energy.service_hot_water = shw
    room.properties.energy.add_default_ideal_air()
    model = Model('TinyHouse', [room])

    dest_file = os.path.join(directory,
                             'model_energy_service_hot_water.hbjson')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
Esempio n. 25
0
def test_room_add_prefix():
    """Test the room add_prefix method."""
    room = Room.from_box('ShoeBoxZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.5, 0.01)
    table_geo = Face3D.from_rectangle(2, 2, Plane(o=Point3D(1.5, 4, 1)))
    room.add_indoor_shade(Shade('Table', table_geo))
    prefix = 'New'
    room.add_prefix(prefix)

    assert room.name.startswith(prefix)
    for face in room.faces:
        assert face.name.startswith(prefix)
        for ap in face.apertures:
            assert ap.name.startswith(prefix)
    for shd in room.shades:
        assert shd.name.startswith(prefix)
Esempio n. 26
0
def test_run_idf_daylight_control():
    """Test Model.to.idf and run_idf with a model possessing daylight controls."""
    room = Room.from_box('TinyHouseZone', 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)

    room.properties.energy.add_daylight_control_to_center(0.8, 500, 0.5)
    sens_pt = room.properties.energy.daylighting_control.sensor_position
    assert sens_pt.x == pytest.approx(2.5, rel=1e-3)
    assert sens_pt.y == pytest.approx(5, rel=1e-3)
    assert sens_pt.z == pytest.approx(0.8, rel=1e-3)
    room.move(Vector3D(5, 5, 0))
    assert room.properties.energy.daylighting_control.sensor_position == \
        sens_pt.move(Vector3D(5, 5, 0))

    model = Model('TinyHouse', [room])

    # Get the input SimulationParameter
    sim_par = SimulationParameter()
    sim_par.output.add_zone_energy_use()
    ddy_file = './tests/ddy/chicago.ddy'
    sim_par.sizing_parameter.add_from_ddy_996_004(ddy_file)
    sim_par.run_period.end_date = Date(6, 7)
    sim_par.run_period.start_date = Date(6, 1)

    # create the IDF string for simulation paramters and model
    idf_str = '\n\n'.join((sim_par.to_idf(), model.to.idf(model)))

    # write the final string into an IDF
    idf = os.path.join(folders.default_simulation_folder, 'test_file_daylight',
                       'in.idf')
    write_to_file(idf, idf_str, True)

    # prepare the IDF for simulation
    epw_file = './tests/simulation/chicago.epw'
    prepare_idf_for_simulation(idf, epw_file)

    # run the IDF through EnergyPlus
    sql, zsz, rdd, html, err = run_idf(idf, epw_file)

    assert os.path.isfile(sql)
    assert os.path.isfile(err)
    err_obj = Err(err)
    assert 'EnergyPlus Completed Successfully' in err_obj.file_contents
Esempio n. 27
0
def test_get_doors_by_name():
    """Test the get_doors_by_name method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    north_face = room[1]
    door_verts = [
        Point3D(2, 10, 0.1),
        Point3D(1, 10, 0.1),
        Point3D(1, 10, 2.5),
        Point3D(2, 10, 2.5)
    ]
    door = Door('Front Door', Face3D(door_verts))
    north_face.add_door(door)
    model = Model('Tiny House', [room])

    assert len(model.get_doors_by_name(['FrontDoor'])) == 1
    with pytest.raises(ValueError):
        model.get_doors_by_name(['NotADoor'])
def test_writer_to_idf():
    """Test the Room to_idf method."""
    room = Room.from_box('ClosedOffice', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    assert hasattr(room.to, 'idf')
    idf_string = room.to.idf(room)
    assert 'ClosedOffice,' in idf_string
    assert 'Zone,' in idf_string
    assert 'People' in idf_string
    assert 'Lights' in idf_string
    assert 'ElectricEquipment' in idf_string
    assert 'GasEquipment' not in idf_string
    assert 'ZoneInfiltration:DesignFlowRate' in idf_string
    assert 'DesignSpecification:OutdoorAir' in idf_string
    assert 'HVACTemplate:Thermostat' in idf_string
    assert 'HVACTemplate:Zone:IdealLoadsAirSystem' not in idf_string
Esempio n. 29
0
def test_shades_by_identifier():
    """Test the shades_by_identifier method."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    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].move_shades(Vector3D(0, 0, -0.5))
    model = Model('TinyHouse', [room])

    assert len(
        model.shades_by_identifier(['TinyHouseZone_Back_Glz0_OutOverhang0'
                                    ])) == 1
    with pytest.raises(ValueError):
        model.shades_by_identifier(['NotAShade'])

    model.remove_assigned_shades()
    with pytest.raises(ValueError):
        model.shades_by_identifier(['TinyHouseZone_Back_Glz0_OutOverhang0'])
Esempio n. 30
0
def test_ventilation_opening_parent():
    """Test the VentilationOpening with a parent."""
    room = Room.from_box('ShoeBoxZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    aperture = south_face.apertures[0]

    ventilation = VentilationOpening()
    assert not ventilation.has_parent
    assert ventilation.parent is None

    with pytest.raises(AssertionError):
        aperture.properties.energy.vent_opening = ventilation

    aperture.is_operable = True
    aperture.properties.energy.vent_opening = ventilation
    assert ventilation.has_parent
    assert ventilation.parent.identifier == aperture.identifier