Exemple #1
0
def test_check_duplicate_schedule_identifiers():
    """Test the check_duplicate_schedule_identifiers method."""
    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)
    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))
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.6, schedule_types.fractional)
    half_occ = ScheduleRuleset.from_constant_value(
        'Half Occupied', 0.5, schedule_types.fractional)
    south_face.apertures[0].outdoor_shades[0].properties.energy.transmittance_schedule = \
        fritted_glass_trans
    room.properties.energy.people = People('Office Occ', 0.05, half_occ)
    model = Model('TinyHouse', [room])

    assert model.properties.energy.check_duplicate_schedule_identifiers(False)
    half_occ.unlock()
    half_occ.identifier = 'Fritted Glass'
    half_occ.lock()
    assert not model.properties.energy.check_duplicate_schedule_identifiers(False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_schedule_identifiers(True)
Exemple #2
0
def test_setpoint_equality():
    """Test the equality of Setpoint objects."""
    simple_heat = ScheduleDay(
        'Simple Weekday HtgSetp', [18, 21, 18],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    simple_cool = ScheduleDay(
        'Simple Weekday ClgSetp', [28, 24, 28],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None,
                                 schedule_types.temperature)
    cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None,
                                 schedule_types.temperature)
    heat_setpt_2 = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    cool_setpt_2 = ScheduleRuleset.from_constant_value(
        'Office Cooling', 24, schedule_types.temperature)

    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt)
    setpoint_dup = setpoint.duplicate()
    setpoint_alt = Setpoint('Office Setpoint', heat_setpt_2, cool_setpt_2)

    assert setpoint is setpoint
    assert setpoint is not setpoint_dup
    assert setpoint == setpoint_dup
    setpoint_dup.humidifying_setpoint = 30
    assert setpoint != setpoint_dup
    assert setpoint != setpoint_alt
Exemple #3
0
def test_program_type_setability():
    """Test the setting of properties of ProgramType."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office,
                                   None, schedule_types.fractional)
    light_schedule = occ_schedule.duplicate()
    light_schedule.identifier = 'Office Lighting-Equip Schedule'
    light_schedule.default_day_schedule.values = [0.25, 1, 0.25]
    equip_schedule = light_schedule.duplicate()
    inf_schedule = ScheduleRuleset.from_constant_value(
        'Infiltration Schedule', 1, schedule_types.fractional)
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating Schedule', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling Schedule', 24, schedule_types.temperature)

    people = People('Open Office People', 0.05, occ_schedule)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule)
    infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program')

    assert office_program.identifier == 'Open Office Program'
    office_program.identifier = 'Office Program'
    assert office_program.identifier == 'Office Program'
    assert office_program.people is None
    office_program.people = people
    assert office_program.people == people
    assert office_program.lighting is None
    office_program.lighting = lighting
    assert office_program.lighting == lighting
    assert office_program.electric_equipment is None
    office_program.electric_equipment = equipment
    assert office_program.electric_equipment == equipment
    assert office_program.infiltration is None
    office_program.infiltration = infiltration
    assert office_program.infiltration == infiltration
    assert office_program.ventilation is None
    office_program.ventilation = ventilation
    assert office_program.ventilation == ventilation
    assert office_program.setpoint is None
    office_program.setpoint = setpoint
    assert office_program.setpoint == setpoint

    with pytest.raises(AssertionError):
        office_program.people = lighting
    with pytest.raises(AssertionError):
        office_program.lighting = equipment
    with pytest.raises(AssertionError):
        office_program.electric_equipment = people
    with pytest.raises(AssertionError):
        office_program.infiltration = people
    with pytest.raises(AssertionError):
        office_program.ventilation = setpoint
    with pytest.raises(AssertionError):
        office_program.setpoint = ventilation
Exemple #4
0
def test_program_type_dict_methods():
    """Test the to/from dict methods."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office,
                                   None, schedule_types.fractional)
    light_schedule = occ_schedule.duplicate()
    light_schedule.identifier = 'Office Lighting-Equip Schedule'
    light_schedule.default_day_schedule.values = [0.25, 1, 0.25]
    equip_schedule = light_schedule.duplicate()
    inf_schedule = ScheduleRuleset.from_constant_value(
        'Infiltration Schedule', 1, schedule_types.fractional)
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating Schedule', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling Schedule', 24, schedule_types.temperature)

    people = People('Open Office People', 0.05, occ_schedule)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule)
    infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program', people, lighting,
                                 equipment, None, None, infiltration,
                                 ventilation, setpoint)

    prog_dict = office_program.to_dict()
    new_office_program = ProgramType.from_dict(prog_dict)
    assert new_office_program == office_program
    assert prog_dict == new_office_program.to_dict()
Exemple #5
0
def model_energy_window_ventilation(directory):
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.add_default_ideal_air()
    south_face = room[3]
    north_face = room[1]
    south_face.apertures_by_ratio(0.4, 0.01)
    north_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].is_operable = True
    north_face.apertures[0].is_operable = True

    heat_setpt = ScheduleRuleset.from_constant_value(
        'House Heating', 20, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'House Cooling', 28, schedule_types.temperature)
    setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt)
    room.properties.energy.setpoint = setpoint

    vent_control = VentilationControl(22, 27, 12, 30)
    room.properties.energy.window_vent_control = vent_control
    ventilation = VentilationOpening(wind_cross_vent=True)
    room.properties.energy.assign_ventilation_opening(ventilation)

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

    dest_file = os.path.join(directory, 'model_energy_window_ventilation.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
Exemple #6
0
def test_check_duplicate_schedule_type_limit_names():
    """Test the check_duplicate_schedule_type_limit_names method."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.hvac = IdealAirSystem()
    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))
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.6, schedule_types.fractional)
    on_off = ScheduleTypeLimit('On-off', 0, 1, 'Discrete')
    full_occ = ScheduleRuleset.from_constant_value('Occupied', 1, on_off)
    south_face.apertures[0].outdoor_shades[0].properties.energy.transmittance_schedule = \
        fritted_glass_trans
    room.properties.energy.people = People('Office Occ', 0.05, full_occ)
    model = Model('Tiny House', [room])

    assert model.properties.energy.check_duplicate_schedule_type_limit_names(
        False)
    full_occ.unlock()
    new_sch_type = ScheduleTypeLimit('Fractional', 0, 1, 'Discrete')
    full_occ.schedule_type_limit = new_sch_type
    full_occ.lock()
    assert not model.properties.energy.check_duplicate_schedule_type_limit_names(
        False)
    with pytest.raises(ValueError):
        model.properties.energy.check_duplicate_schedule_type_limit_names(True)
Exemple #7
0
def test_people_setability():
    """Test the setting of properties of People."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy', simple_office, None,
                                   schedule_types.fractional)
    constant_ppl = ScheduleRuleset.from_constant_value(
        'Constant Occ', 1, schedule_types.fractional)
    sleeping_act = ScheduleRuleset.from_constant_value(
        'Sleeping Activity', 95, schedule_types.activity_level)
    people = People('Open Office Zone People', 0.05, occ_schedule)

    people.identifier = 'Office Zone People'
    assert people.identifier == 'Office Zone People'
    people.people_per_area = 0.1
    assert people.people_per_area == 0.1
    assert people.area_per_person == 10
    people.area_per_person = 20
    assert people.area_per_person == 20
    assert people.people_per_area == 0.05
    people.occupancy_schedule = constant_ppl
    assert people.occupancy_schedule == constant_ppl
    people.activity_schedule = sleeping_act
    assert people.activity_schedule.schedule_type_limit == schedule_types.activity_level
    assert people.activity_schedule.values() == [95] * 8760
    people.radiant_fraction = 0.4
    assert people.radiant_fraction == 0.4
    people.latent_fraction = 0.2
    assert people.latent_fraction == 0.2
def test_ideal_air_init_from_idf():
    """Test the initialization of IdealAirSystem from_idf."""
    ideal_air = IdealAirSystem('Test_System')
    with pytest.raises(AssertionError):
        ideal_air.to_idf()

    zone_id = 'ShoeBox'
    room = Room.from_box(zone_id, 5, 10, 3, 90, Point3D(0, 0, 3))
    room.properties.energy.add_default_ideal_air()
    ideal_air = room.properties.energy.hvac
    with pytest.raises(AssertionError):
        ideal_air.to_idf()

    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling', 24, schedule_types.temperature)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt)
    room.properties.energy.setpoint = setpoint

    idf_str = ideal_air.to_idf()
    schedule_dict = {}
    rebuilt_ideal_air, rebuilt_zone_id = IdealAirSystem.from_idf(
        idf_str, schedule_dict)
    assert ideal_air == rebuilt_ideal_air
    assert zone_id == rebuilt_zone_id
Exemple #9
0
def test_setpoint_init_from_idf_humidity():
    """Test the initialization of Setpoint from_idf with humidity setpoints."""
    simple_heat = ScheduleDay(
        'Simple Weekday HtgSetp', [18, 21, 18],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    simple_cool = ScheduleDay(
        'Simple Weekday ClgSetp', [28, 24, 28],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    heat_setpt = ScheduleRuleset('Office Heating', simple_heat, None,
                                 schedule_types.temperature)
    cool_setpt = ScheduleRuleset('Office Cooling', simple_cool, None,
                                 schedule_types.temperature)
    humid_setpt = ScheduleRuleset.from_constant_value('Office Humid', 30,
                                                      schedule_types.humidity)
    dehumid_setpt = ScheduleRuleset.from_constant_value(
        'Office Dehumid', 60, schedule_types.humidity)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt, humid_setpt,
                        dehumid_setpt)
    sched_dict = {
        heat_setpt.identifier: heat_setpt,
        cool_setpt.identifier: cool_setpt,
        humid_setpt.identifier: humid_setpt,
        dehumid_setpt.identifier: dehumid_setpt
    }

    zone_id = 'Test Zone'
    idf_str = setpoint.to_idf(zone_id)
    humid_idf_str = setpoint.to_idf_humidistat(zone_id)
    rebuilt_setpoint = Setpoint.from_idf(idf_str, sched_dict)
    rebuilt_setpoint.add_humidity_from_idf(humid_idf_str, sched_dict)
    assert setpoint == rebuilt_setpoint
Exemple #10
0
def test_dict_to_object_load():
    """Test the dict_to_object method with Setpoint objects."""
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling', 24, schedule_types.temperature)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt)

    setpoint_dict = setpoint.to_dict()
    new_setpoint = dict_to_object(setpoint_dict)
    assert isinstance(new_setpoint, Setpoint)
Exemple #11
0
def test_run_idf_window_ventilation():
    """Test the Model.to.idf and run_idf method with a model possessing operable windows."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.add_default_ideal_air()
    south_face = room[3]
    north_face = room[1]
    south_face.apertures_by_ratio(0.4, 0.01)
    north_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].is_operable = True
    north_face.apertures[0].is_operable = True

    heat_setpt = ScheduleRuleset.from_constant_value(
        'House Heating', 20, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'House Cooling', 28, schedule_types.temperature)
    setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt)
    room.properties.energy.setpoint = setpoint

    vent_control = VentilationControl(22, 27, 12, 30)
    room.properties.energy.window_vent_control = vent_control
    ventilation = VentilationOpening(wind_cross_vent=True)
    op_aps = room.properties.energy.assign_ventilation_opening(ventilation)
    assert len(op_aps) == 2

    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_window_vent', '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
Exemple #12
0
def test_setpoint_lockability():
    """Test the lockability of Setpoint objects."""
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling', 24, schedule_types.temperature)
    setpoint = Setpoint('Office Setpoint', heat_setpt, cool_setpt)

    setpoint.heating_setpoint = 20
    setpoint.lock()
    with pytest.raises(AttributeError):
        setpoint.heating_setpoint = 22
    setpoint.unlock()
    setpoint.heating_setpoint = 22
Exemple #13
0
def test_dict_to_object_sch():
    """Test the dict_to_object method with ScheduleRuleset objects."""
    sch_obj = ScheduleRuleset.from_constant_value(
        'Office Heating', 21, schedule_types.temperature)
    sch_dict = sch_obj.to_dict()
    new_sch = dict_to_object(sch_dict)
    assert isinstance(new_sch, ScheduleRuleset)
Exemple #14
0
def test_to_dict():
    """Test the Building to_dict method with energy properties."""
    tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6,
                                                   Plane(o=Point3D(5, -10, 6)))
    tree_canopy_geo2 = Face3D.from_regular_polygon(
        6, 2, Plane(o=Point3D(-5, -10, 3)))
    tree_canopy = ContextShade('TreeCanopy',
                               [tree_canopy_geo1, tree_canopy_geo2])

    sd = tree_canopy.to_dict()
    assert 'properties' in sd
    assert sd['properties']['type'] == 'ContextShadeProperties'
    assert 'energy' in sd['properties']
    assert sd['properties']['energy']['type'] == 'ContextShadeEnergyProperties'
    assert 'construction' not in sd['properties']['energy'] or \
        sd['properties']['energy']['construction'] is None

    bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True)
    tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5,
                                                     schedule_types.fractional)
    tree_canopy.properties.energy.construction = bright_leaves
    tree_canopy.properties.energy.transmittance_schedule = tree_trans

    sd = tree_canopy.to_dict()
    assert sd['properties']['energy']['construction'] is not None
    assert sd['properties']['energy']['transmittance_schedule'] is not None
Exemple #15
0
def test_lighting_equality():
    """Test the equality of Lighting objects."""
    weekday_office = ScheduleDay(
        'Weekday Office Lighting', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Lighting', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_rule = ScheduleRule(saturday_office)
    weekend_rule.apply_weekend = True
    schedule = ScheduleRuleset('Office Lighting', weekday_office,
                               [weekend_rule], schedule_types.fractional)
    lighting = Lighting('Open Office Zone Lighting', 10, schedule)
    lighting_dup = lighting.duplicate()
    lighting_alt = Lighting(
        'Open Office Zone Lighting', 10,
        ScheduleRuleset.from_constant_value('Constant', 1,
                                            schedule_types.fractional))

    assert lighting is lighting
    assert lighting is not lighting_dup
    assert lighting == lighting_dup
    lighting_dup.watts_per_area = 6
    assert lighting != lighting_dup
    assert lighting != lighting_alt
def dup_setpoint(hb_obj):
    """Duplicate a setpoint object assigned to a Room or ProgramType."""
    # try to get the setpoint object assgined to the Room or ProgramType
    try:  # assume it's a Room
        setpt_obj = hb_obj.properties.energy.setpoint
    except AttributeError:  # it's a ProgramType
        setpt_obj = hb_obj.setpoint

    try:  # duplicate the setpoint object
        return setpt_obj.duplicate()
    except AttributeError:  # create a new object if it does not exist
        heat_sch = ScheduleRuleset.from_constant_value(
            '{}_HtgSetp'.format(hb_obj.identifier), -50, _type_lib.temperature)
        cool_sch = ScheduleRuleset.from_constant_value(
            '{}_ClgSetp'.format(hb_obj.identifier), 50, _type_lib.temperature)
        return Setpoint('{}_Setpoint'.format(hb_obj.identifier), heat_sch, cool_sch)
Exemple #17
0
def test_to_dict():
    """Test the Shade to_dict method with energy properties."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))

    shade_dict = shade.to_dict()
    assert 'properties' in shade_dict
    assert shade_dict['properties']['type'] == 'ShadeProperties'
    assert 'energy' in shade_dict['properties']
    assert shade_dict['properties']['energy'][
        'type'] == 'ShadeEnergyProperties'

    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    shade_dict = shade.to_dict()
    assert 'construction' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy']['construction'][
        'solar_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction'][
        'visible_reflectance'] == 0.5
    assert shade_dict['properties']['energy']['construction']['is_specular']

    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans
    shade_dict = shade.to_dict()
    assert 'transmittance_schedule' in shade_dict['properties']['energy']
    assert shade_dict['properties']['energy'][
        'transmittance_schedule'] is not None
Exemple #18
0
def test_writer_to_idf():
    """Test the Shade to_idf method."""
    verts = [
        Point3D(0, 0, 0),
        Point3D(1, 0, 0),
        Point3D(1, 0, 3),
        Point3D(0, 0, 3)
    ]
    shade = Shade('overhang', Face3D(verts))

    assert hasattr(shade.to, 'idf')
    idf_string = shade.to.idf(shade)
    assert 'overhang,' in idf_string
    assert 'Shading:Building:Detailed,' in idf_string
    assert 'ShadingProperty:Reflectance' not in idf_string

    shade = Shade('overhang', Face3D(verts))
    light_shelf = ShadeConstruction('Light Shelf', 0.5, 0.5, True)
    shade.properties.energy.construction = light_shelf
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'FrittedGlass', 0.5, schedule_types.fractional)
    shade.properties.energy.transmittance_schedule = fritted_glass_trans

    assert hasattr(shade.to, 'idf')
    idf_string = shade.to.idf(shade)
    assert 'overhang,' in idf_string
    assert 'Shading:Building:Detailed,' in idf_string
    assert 'ShadingProperty:Reflectance' in idf_string
    assert 'FrittedGlass' in idf_string
Exemple #19
0
def test_people_equality():
    """Test the equality of People objects."""
    weekday_office = ScheduleDay(
        'Weekday Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Occupancy', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_rule = ScheduleRule(saturday_office)
    weekend_rule.apply_weekend = True
    occ_schedule = ScheduleRuleset('Office Occupancy', weekday_office,
                                   [weekend_rule], schedule_types.fractional)
    people = People('Open Office Zone People', 0.05, occ_schedule)
    people_dup = people.duplicate()
    people_alt = People(
        'Open Office Zone People', 0.05,
        ScheduleRuleset.from_constant_value('Constant', 1,
                                            schedule_types.fractional))

    assert people is people
    assert people is not people_dup
    assert people == people_dup
    people_dup.people_per_area = 0.06
    assert people != people_dup
    assert people != people_alt
Exemple #20
0
def test_energy_properties():
    """Test the existence of the Model energy properties."""
    room = Room.from_box('Tiny House Zone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.hvac = IdealAirSystem()
    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))
    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)
    south_face.apertures[0].outdoor_shades[0].properties.energy.transmittance_schedule = \
        fritted_glass_trans
    model = Model('Tiny House', [room])

    assert hasattr(model.properties, 'energy')
    assert isinstance(model.properties.energy, ModelEnergyProperties)
    assert isinstance(model.properties.host, Model)
    assert len(model.properties.energy.materials) == 15
    for mat in model.properties.energy.materials:
        assert isinstance(mat, _EnergyMaterialBase)
    assert len(model.properties.energy.constructions) == 14
    for cnst in model.properties.energy.constructions:
        assert isinstance(
            cnst, (WindowConstruction, OpaqueConstruction, ShadeConstruction))
    assert len(model.properties.energy.face_constructions) == 0
    assert len(model.properties.energy.construction_sets) == 0
    assert isinstance(model.properties.energy.global_construction_set,
                      ConstructionSet)
    assert len(model.properties.energy.schedule_type_limits) == 3
    assert len(model.properties.energy.schedules) == 8
    assert len(model.properties.energy.shade_schedules) == 1
    assert len(model.properties.energy.room_schedules) == 0
    assert len(model.properties.energy.program_types) == 1
Exemple #21
0
def test_lighting_setability():
    """Test the setting of properties of Lighting."""
    simple_office = ScheduleDay(
        'Simple Weekday Light', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Lighting', simple_office, None,
                               schedule_types.fractional)
    constant = ScheduleRuleset.from_constant_value('Constant Light', 1,
                                                   schedule_types.fractional)
    lighting = Lighting('Open Office Zone Lighting', 10, schedule)

    lighting.identifier = 'Office Zone Lighting'
    assert lighting.identifier == 'Office Zone Lighting'
    lighting.watts_per_area = 6
    assert lighting.watts_per_area == 6
    lighting.schedule = constant
    assert lighting.schedule == constant
    assert lighting.schedule.values() == [1] * 8760
    lighting.return_air_fraction = 0.1
    assert lighting.return_air_fraction == 0.1
    lighting.radiant_fraction = 0.4
    assert lighting.radiant_fraction == 0.4
    lighting.visible_fraction = 0.2
    assert lighting.visible_fraction == 0.2
    lighting.baseline_watts_per_area = 5.0
    assert lighting.baseline_watts_per_area == 5.0
Exemple #22
0
def test_duplicate():
    """Test what happens to energy properties when duplicating a Room2D."""
    tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6,
                                                   Plane(o=Point3D(5, -10, 6)))
    tree_canopy_geo2 = Face3D.from_regular_polygon(
        6, 2, Plane(o=Point3D(-5, -10, 3)))
    shade_original = ContextShade('TreeCanopy',
                                  [tree_canopy_geo1, tree_canopy_geo2])
    shade_dup_1 = shade_original.duplicate()

    bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True)
    tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5,
                                                     schedule_types.fractional)

    assert shade_original.properties.energy.host is shade_original
    assert shade_dup_1.properties.energy.host is shade_dup_1
    assert shade_original.properties.energy.host is not \
        shade_dup_1.properties.energy.host

    assert shade_original.properties.energy.construction == \
        shade_dup_1.properties.energy.construction
    shade_dup_1.properties.energy.construction = bright_leaves
    assert shade_original.properties.energy.construction != \
        shade_dup_1.properties.energy.construction

    shade_dup_2 = shade_dup_1.duplicate()

    assert shade_dup_1.properties.energy.construction == \
        shade_dup_2.properties.energy.construction
    shade_dup_2.properties.energy.construction = None
    assert shade_dup_1.properties.energy.construction != \
        shade_dup_2.properties.energy.construction
def test_equipment_equality():
    """Test the equality of ElectricEquipment objects."""
    weekday_office = ScheduleDay(
        'Weekday Office Equip', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Equip', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_rule = ScheduleRule(saturday_office)
    weekend_rule.apply_weekend = True
    schedule = ScheduleRuleset('Office Equip', weekday_office, [weekend_rule],
                               schedule_types.fractional)
    equipment = ElectricEquipment('Open Office Zone Equip', 10, schedule)
    equipment_dup = equipment.duplicate()
    equipment_alt = ElectricEquipment(
        'Open Office Zone Equip', 10,
        ScheduleRuleset.from_constant_value('Constant', 1,
                                            schedule_types.fractional))

    assert equipment is equipment
    assert equipment is not equipment_dup
    assert equipment == equipment_dup
    equipment_dup.watts_per_area = 6
    assert equipment != equipment_dup
    assert equipment != equipment_alt
Exemple #24
0
def test_program_type_init():
    """Test the initialization of ProgramType and basic properties."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office,
                                   None, schedule_types.fractional)
    light_schedule = occ_schedule.duplicate()
    light_schedule.identifier = 'Office Lighting-Equip Schedule'
    light_schedule.default_day_schedule.values = [0.25, 1, 0.25]
    equip_schedule = light_schedule.duplicate()
    inf_schedule = ScheduleRuleset.from_constant_value(
        'Infiltration Schedule', 1, schedule_types.fractional)
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating Schedule', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling Schedule', 24, schedule_types.temperature)

    people = People('Open Office People', 0.05, occ_schedule)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule)
    infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program', people, lighting,
                                 equipment, None, None, infiltration,
                                 ventilation, setpoint)

    str(office_program)  # test the string representation

    assert office_program.identifier == 'Open Office Program'
    assert isinstance(office_program.people, People)
    assert office_program.people == people
    assert isinstance(office_program.lighting, Lighting)
    assert office_program.lighting == lighting
    assert isinstance(office_program.electric_equipment, ElectricEquipment)
    assert office_program.electric_equipment == equipment
    assert office_program.gas_equipment is None
    assert isinstance(office_program.infiltration, Infiltration)
    assert office_program.infiltration == infiltration
    assert isinstance(office_program.ventilation, Ventilation)
    assert office_program.ventilation == ventilation
    assert isinstance(office_program.setpoint, Setpoint)
    assert office_program.setpoint == setpoint
    assert len(office_program.schedules) == 7
    assert len(office_program.schedules_unique) == 6
Exemple #25
0
def create_hb_constant_schedule(_name, _type_limit='Fractional'):
    type_limit = schedule_type_limit_by_identifier( _type_limit )

    schedule = ScheduleRuleset.from_constant_value(
        clean_and_id_ep_string(_name), 1, type_limit)

    schedule.display_name = _name

    return schedule
Exemple #26
0
def test_energy_properties():
    """Test the existence of the Model energy properties."""
    pts_1 = (Point3D(0, 0, 3), Point3D(0, 10,
                                       3), Point3D(10, 10,
                                                   3), Point3D(10, 0, 3))
    pts_2 = (Point3D(10, 0, 3), Point3D(10, 10,
                                        3), Point3D(20, 10,
                                                    3), Point3D(20, 0, 3))
    pts_3 = (Point3D(0, 10, 3), Point3D(0, 20,
                                        3), Point3D(10, 20,
                                                    3), Point3D(10, 10, 3))
    pts_4 = (Point3D(10, 10, 3), Point3D(10, 20,
                                         3), Point3D(20, 20,
                                                     3), Point3D(20, 10, 3))
    room2d_1 = Room2D('Office1', Face3D(pts_1), 3)
    room2d_2 = Room2D('Office2', Face3D(pts_2), 3)
    room2d_3 = Room2D('Office3', Face3D(pts_3), 3)
    room2d_4 = Room2D('Office4', Face3D(pts_4), 3)
    story = Story('OfficeFloor', [room2d_1, room2d_2, room2d_3, room2d_4])
    story.solve_room_2d_adjacency(0.01)
    story.set_outdoor_window_parameters(SimpleWindowRatio(0.4))
    story.multiplier = 4
    for room in story.room_2ds:
        room.properties.energy.program_type = office_program
        room.properties.energy.add_default_ideal_air()
    building = Building('OfficeBuilding', [story])

    tree_canopy_geo1 = Face3D.from_regular_polygon(6, 6,
                                                   Plane(o=Point3D(5, -10, 6)))
    tree_canopy_geo2 = Face3D.from_regular_polygon(
        6, 2, Plane(o=Point3D(-5, -10, 3)))
    tree_canopy = ContextShade('TreeCanopy',
                               [tree_canopy_geo1, tree_canopy_geo2])
    bright_leaves = ShadeConstruction('Bright Light Leaves', 0.5, 0.5, True)
    tree_canopy.properties.energy.construction = bright_leaves
    tree_trans = ScheduleRuleset.from_constant_value('Tree Transmittance', 0.5,
                                                     schedule_types.fractional)
    tree_canopy.properties.energy.transmittance_schedule = tree_trans

    model = Model('NewDevelopment', [building], [tree_canopy])

    assert hasattr(model.properties, 'energy')
    assert isinstance(model.properties.energy, ModelEnergyProperties)
    assert isinstance(model.properties.host, Model)
    assert len(model.properties.energy.materials) == 0
    for mat in model.properties.energy.materials:
        assert isinstance(mat, _EnergyMaterialBase)
    assert len(model.properties.energy.constructions) == 1
    for cnst in model.properties.energy.constructions:
        assert isinstance(cnst, (WindowConstruction, OpaqueConstruction,
                                 ShadeConstruction, AirBoundaryConstruction))
    assert len(model.properties.energy.shade_constructions) == 1
    assert len(model.properties.energy.construction_sets) == 0
    assert len(model.properties.energy.schedule_type_limits) == 3
    assert len(model.properties.energy.schedules) == 8
    assert len(model.properties.energy.shade_schedules) == 1
    assert len(model.properties.energy.program_types) == 1
Exemple #27
0
def test_schedule_ruleset_from_constant_value():
    """Test the initialization of ScheduleRuleset from_constant_value."""
    sched = ScheduleRuleset.from_constant_value('Shade Transmittance', 0.5)

    assert sched.identifier == 'Shade Transmittance'
    assert len(sched.default_day_schedule.values) == 1
    assert sched.default_day_schedule.values[0] == 0.5
    assert len(sched.schedule_rules) == 0
    assert sched.summer_designday_schedule is None
    assert sched.winter_designday_schedule is None
Exemple #28
0
def test_set_transmittance_schedule():
    """Test the setting of transmittance_schedule on a Shade."""
    shade = Shade.from_vertices('overhang',
                                [[0, 0, 3], [1, 0, 3], [1, 1, 3], [0, 1, 3]])

    fritted_glass_trans = ScheduleRuleset.from_constant_value(
        'Fritted Glass', 0.5, schedule_types.fractional)

    shade.properties.energy.transmittance_schedule = fritted_glass_trans
    assert shade.properties.energy.transmittance_schedule == fritted_glass_trans
def test_schedule_ruleset_average_schedules_date_range():
    """Test the ScheduleRuleset average_schedules method with schedules over a date range."""
    weekday_school = ScheduleDay(
        'Weekday School Year', [0.1, 1, 0.1],
        [Time(0, 0), Time(8, 0), Time(17, 0)])
    weekend_school = ScheduleDay('Weekend School Year', [0.1])
    weekday_summer = ScheduleDay(
        'Weekday Summer', [0, 0.5, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_summer = ScheduleDay('Weekend Summer', [0])

    summer_weekday_rule = ScheduleRule(weekday_summer,
                                       start_date=Date(7, 1),
                                       end_date=Date(9, 1))
    summer_weekday_rule.apply_weekday = True
    summer_weekend_rule = ScheduleRule(weekend_summer,
                                       start_date=Date(7, 1),
                                       end_date=Date(9, 1))
    summer_weekend_rule.apply_weekend = True
    summer_weekend_rule.apply_holiday = True
    school_weekend_rule = ScheduleRule(weekend_school)
    school_weekend_rule.apply_weekend = True
    school_weekend_rule.apply_holiday = True

    summer_design = ScheduleDay(
        'School Summer Design', [0, 1, 0.25],
        [Time(0, 0), Time(6, 0), Time(18, 0)])
    winter_design = ScheduleDay('School Winter Design', [0])

    all_rules = [summer_weekday_rule, summer_weekend_rule, school_weekend_rule]
    school_schedule = ScheduleRuleset('School Occupancy', weekday_school,
                                      all_rules, schedule_types.fractional,
                                      summer_design, winter_design)
    lobby_schedule = ScheduleRuleset.from_constant_value(
        'Lobby Occupancy', 0.1, schedule_types.fractional)

    school_avg = ScheduleRuleset.average_schedules(
        'Office Average', [school_schedule, lobby_schedule])

    week_vals = school_avg.values(end_date=Date(1, 7))
    avg_vals = [
        0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.55, 0.55, 0.55, 0.55, 0.55,
        0.55, 0.55, 0.55, 0.55, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1
    ]
    assert week_vals[:24] == [0.1] * 24
    assert week_vals[24:48] == avg_vals

    week_vals = school_avg.values(start_date=Date(7, 1), end_date=Date(7, 7))
    avg_vals = [
        0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.3, 0.3, 0.3,
        0.3, 0.3, 0.3, 0.3, 0.3, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05
    ]
    assert week_vals[:24] == [0.05] * 24
    assert week_vals[24:48] == avg_vals
Exemple #30
0
def test_program_type_diversify():
    """Test the diversify methods."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy Schedule', simple_office,
                                   None, schedule_types.fractional)
    light_schedule = occ_schedule.duplicate()
    light_schedule.identifier = 'Office Lighting-Equip Schedule'
    light_schedule.default_day_schedule.values = [0.25, 1, 0.25]
    equip_schedule = light_schedule.duplicate()
    inf_schedule = ScheduleRuleset.from_constant_value(
        'Infiltration Schedule', 1, schedule_types.fractional)
    heat_setpt = ScheduleRuleset.from_constant_value(
        'Office Heating Schedule', 21, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'Office Cooling Schedule', 24, schedule_types.temperature)

    people = People('Open Office People', 0.05, occ_schedule)
    lighting = Lighting('Open Office Lighting', 10, light_schedule)
    equipment = ElectricEquipment('Open Office Equipment', 10, equip_schedule)
    infiltration = Infiltration('Office Infiltration', 0.00015, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program', people, lighting,
                                 equipment, None, None, infiltration,
                                 ventilation, setpoint)

    div_programs = office_program.diversify(10)
    assert len(div_programs) == 10
    for prog in div_programs:
        assert isinstance(prog, ProgramType)
        assert prog.people.people_per_area != people.people_per_area
        assert prog.lighting.watts_per_area != lighting.watts_per_area
        assert prog.electric_equipment.watts_per_area != equipment.watts_per_area
        assert prog.infiltration.flow_per_exterior_area != \
            infiltration.flow_per_exterior_area

    div_programs = office_program.diversify(10, schedule_offset=0)
    for prog in div_programs:
        assert prog.people.occupancy_schedule == people.occupancy_schedule