Example #1
0
def test_infiltration_dict_methods():
    """Test the to/from dict methods."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)

    inf_dict = infiltration.to_dict()
    new_infiltration = Infiltration.from_dict(inf_dict)
    assert new_infiltration == infiltration
    assert inf_dict == new_infiltration.to_dict()
Example #2
0
def dict_to_load(load_dict, raise_exception=True):
    """Get a Python object of any Load from a dictionary.

    Args:
        load_dict: A dictionary of any Honeybee energy load. Note
            that this should be a non-abridged dictionary to be valid.
        raise_exception: Boolean to note whether an excpetion should be raised
            if the object is not identified as a load. Default: True.

    Returns:
        A Python object derived from the input load_dict.
    """
    try:  # get the type key from the dictionary
        load_type = load_dict['type']
    except KeyError:
        raise ValueError('Load dictionary lacks required "type" key.')

    if load_type == 'People':
        return People.from_dict(load_dict)
    elif load_type == 'Lighting':
        return Lighting.from_dict(load_dict)
    elif load_type == 'ElectricEquipment':
        return ElectricEquipment.from_dict(load_dict)
    elif load_type == 'GasEquipment':
        return GasEquipment.from_dict(load_dict)
    elif load_type == 'Infiltration':
        return Infiltration.from_dict(load_dict)
    elif load_type == 'Ventilation':
        return Ventilation.from_dict(load_dict)
    elif load_type == 'Setpoint':
        return Setpoint.from_dict(load_dict)
    elif raise_exception:
        raise ValueError(
            '{} is not a recognized energy Load type'.format(load_type))
Example #3
0
def test_infiltration_init_from_idf():
    """Test the initialization of Infiltration from_idf."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)
    sched_dict = {schedule.identifier: schedule}

    zone_id = 'Test Zone'
    idf_str = infiltration.to_idf(zone_id)
    rebuilt_infiltration, rebuilt_zone_id = Infiltration.from_idf(
        idf_str, sched_dict)
    assert infiltration == rebuilt_infiltration
    assert zone_id == rebuilt_zone_id
Example #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()
Example #5
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
Example #6
0
def test_infiltration_average():
    """Test the Infiltration.average method."""
    weekday_office = ScheduleDay(
        'Weekday Office Infiltration', [0, 1, 0.5, 0],
        [Time(0, 0), Time(9, 0),
         Time(17, 0), Time(19, 0)])
    weekday_lobby = ScheduleDay(
        'Weekday Lobby Infiltration', [0.1, 1, 0.1],
        [Time(0, 0), Time(8, 0), Time(20, 0)])
    weekend_office = ScheduleDay('Weekend Office Infiltration', [0])
    weekend_lobby = ScheduleDay('Weekend Office Infiltration', [0.1])
    wknd_office_rule = ScheduleRule(weekend_office,
                                    apply_saturday=True,
                                    apply_sunday=True)
    wknd_lobby_rule = ScheduleRule(weekend_lobby,
                                   apply_saturday=True,
                                   apply_sunday=True)
    office_schedule = ScheduleRuleset('Office Infiltration', weekday_office,
                                      [wknd_office_rule],
                                      schedule_types.fractional)
    lobby_schedule = ScheduleRuleset('Lobby Infiltration', weekday_lobby,
                                     [wknd_lobby_rule],
                                     schedule_types.fractional)

    office_inf = Infiltration('Office Infiltration', 0.0003, office_schedule,
                              1, 0, 0)
    lobby_inf = Infiltration('Lobby Infiltration', 0.0006, lobby_schedule, 0.6,
                             0.03, 0.1)

    office_avg = Infiltration.average('Average Infiltration',
                                      [office_inf, lobby_inf])

    assert office_avg.flow_per_exterior_area == pytest.approx(0.00045,
                                                              rel=1e-3)
    assert office_avg.constant_coefficient == pytest.approx(0.8, rel=1e-3)
    assert office_avg.temperature_coefficient == pytest.approx(0.015, rel=1e-3)
    assert office_avg.velocity_coefficient == pytest.approx(0.05, rel=1e-3)

    week_vals = office_avg.schedule.values(end_date=Date(1, 7))
    avg_vals = [
        0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.5, 1.0, 1.0, 1.0,
        1.0, 1.0, 1.0, 1.0, 1.0, 0.75, 0.75, 0.5, 0.05, 0.05, 0.05, 0.05
    ]
    assert week_vals[:24] == [0.05] * 24
    assert week_vals[24:48] == avg_vals
Example #7
0
def test_infiltration_equality():
    """Test the equality of Infiltration objects."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    constant = ScheduleRuleset.from_constant_value('Constant Infiltration', 1,
                                                   schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)
    infiltration_dup = infiltration.duplicate()
    infiltration_alt = Infiltration('Lobby Infiltration', 0.0003, constant)

    assert infiltration is infiltration
    assert infiltration is not infiltration_dup
    assert infiltration == infiltration_dup
    infiltration_dup.flow_per_exterior_area = 0.0006
    assert infiltration != infiltration_dup
    assert infiltration != infiltration_alt
Example #8
0
def test_infiltration_lockability():
    """Test the lockability of Infiltration objects."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)

    infiltration.flow_per_exterior_area = 0.0006
    infiltration.lock()
    with pytest.raises(AttributeError):
        infiltration.flow_per_exterior_area = 0.0008
    with pytest.raises(AttributeError):
        infiltration.schedule.default_day_schedule.remove_value_by_time(
            Time(17, 0))
    infiltration.unlock()
    infiltration.flow_per_exterior_area = 0.0008
    with pytest.raises(AttributeError):
        infiltration.schedule.default_day_schedule.remove_value_by_time(
            Time(17, 0))
Example #9
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
Example #10
0
def test_infiltration_init():
    """Test the initialization of Infiltration and basic properties."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)
    str(infiltration)  # test the string representation

    assert infiltration.identifier == 'Lobby Infiltration'
    assert infiltration.flow_per_exterior_area == 0.0003
    assert infiltration.schedule.identifier == 'Lobby Infiltration Schedule'
    assert infiltration.schedule.schedule_type_limit == schedule_types.fractional
    assert infiltration.schedule == schedule
    assert infiltration.constant_coefficient == 1
    assert infiltration.temperature_coefficient == 0
    assert infiltration.velocity_coefficient == 0
Example #11
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
Example #12
0
def test_program_type_equality():
    """Test the equality of ProgramType objects."""
    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)
    led_lighting = Lighting('LED Office Lighting', 5, 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)
    office_program_dup = office_program.duplicate()
    office_program_alt = ProgramType('Open Office Program', people,
                                     led_lighting, equipment, None, None,
                                     infiltration, ventilation, setpoint)

    assert office_program is office_program
    assert office_program is not office_program_dup
    assert office_program == office_program_dup
    office_program_dup.people.people_per_area = 0.1
    assert office_program != office_program_dup
    assert office_program != office_program_alt
Example #13
0
def test_infiltration_setability():
    """Test the setting of properties of Infiltration."""
    simple_lobby = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Lobby Infiltration Schedule', simple_lobby,
                               None, schedule_types.fractional)
    constant = ScheduleRuleset.from_constant_value('Constant Infiltration', 1,
                                                   schedule_types.fractional)
    infiltration = Infiltration('Lobby Infiltration', 0.0003, schedule)

    infiltration.identifier = 'Lobby Zone Infiltration'
    assert infiltration.identifier == 'Lobby Zone Infiltration'
    infiltration.flow_per_exterior_area = 0.0006
    assert infiltration.flow_per_exterior_area == 0.0006
    infiltration.schedule = constant
    assert infiltration.schedule == constant
    assert infiltration.schedule.values() == [1] * 8760
    infiltration.constant_coefficient = 0.606
    assert infiltration.constant_coefficient == 0.606
    infiltration.temperature_coefficient = 0.03636
    assert infiltration.temperature_coefficient == 0.03636
    infiltration.velocity_coefficient = 0.1177
    assert infiltration.velocity_coefficient == 0.1177
Example #14
0
def test_averaged_program_type():
    """Test the averaged_program_type method."""
    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))
    room2d_1 = Room2D('Office1', Face3D(pts_1), 3)
    room2d_2 = Room2D('Office2', Face3D(pts_2), 3)

    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.0002, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.005, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program', people, lighting, equipment,
                                 None, None, infiltration, ventilation, setpoint)
    plenum_program = ProgramType('Plenum Program')

    room2d_1.properties.energy.program_type = office_program
    room2d_2.properties.energy.program_type = plenum_program

    story = Story('OfficeFloor', [room2d_1, room2d_2])
    story.solve_room_2d_adjacency(0.01)
    story.set_outdoor_window_parameters(SimpleWindowRatio(0.4))
    story.multiplier = 4
    building = Building('OfficeBuilding', [story])

    office_avg = building.properties.energy.averaged_program_type('Office Avg Program')

    assert office_avg.people.people_per_area == pytest.approx(0.025, rel=1e-3)
    assert office_avg.people.occupancy_schedule.default_day_schedule.values == \
        office_program.people.occupancy_schedule.default_day_schedule.values
    assert office_avg.people.latent_fraction == \
        office_program.people.latent_fraction
    assert office_avg.people.radiant_fraction == \
        office_program.people.radiant_fraction

    assert office_avg.lighting.watts_per_area == pytest.approx(5, rel=1e-3)
    assert office_avg.lighting.schedule.default_day_schedule.values == \
        office_program.lighting.schedule.default_day_schedule.values
    assert office_avg.lighting.return_air_fraction == \
        office_program.lighting.return_air_fraction
    assert office_avg.lighting.radiant_fraction == \
        office_program.lighting.radiant_fraction
    assert office_avg.lighting.visible_fraction == \
        office_program.lighting.visible_fraction

    assert office_avg.electric_equipment.watts_per_area == pytest.approx(5, rel=1e-3)
    assert office_avg.electric_equipment.schedule.default_day_schedule.values == \
        office_program.electric_equipment.schedule.default_day_schedule.values
    assert office_avg.electric_equipment.radiant_fraction == \
        office_program.electric_equipment.radiant_fraction
    assert office_avg.electric_equipment.latent_fraction == \
        office_program.electric_equipment.latent_fraction
    assert office_avg.electric_equipment.lost_fraction == \
        office_program.electric_equipment.lost_fraction

    assert office_avg.gas_equipment is None

    assert office_avg.infiltration.flow_per_exterior_area == \
        pytest.approx(0.0001, rel=1e-3)
    assert office_avg.infiltration.schedule.default_day_schedule.values == \
        office_program.infiltration.schedule.default_day_schedule.values
    assert office_avg.infiltration.constant_coefficient == \
        office_program.infiltration.constant_coefficient
    assert office_avg.infiltration.temperature_coefficient == \
        office_program.infiltration.temperature_coefficient
    assert office_avg.infiltration.velocity_coefficient == \
        office_program.infiltration.velocity_coefficient

    assert office_avg.ventilation.flow_per_person == pytest.approx(0.0025, rel=1e-3)
    assert office_avg.ventilation.flow_per_area == pytest.approx(0.00015, rel=1e-3)
    assert office_avg.ventilation.flow_per_zone == pytest.approx(0, rel=1e-3)
    assert office_avg.ventilation.air_changes_per_hour == pytest.approx(0, rel=1e-3)
    assert office_avg.ventilation.schedule is None

    assert office_avg.setpoint.heating_setpoint == pytest.approx(21, rel=1e-3)
    assert office_avg.setpoint.cooling_setpoint == pytest.approx(24, rel=1e-3)
Example #15
0
def test_program_type_average():
    """Test the ProgramType.average method."""
    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.0002, inf_schedule)
    ventilation = Ventilation('Office Ventilation', 0.005, 0.0003)
    setpoint = Setpoint('Office Setpoints', heat_setpt, cool_setpt)
    office_program = ProgramType('Open Office Program', people, lighting,
                                 equipment, None, None, infiltration,
                                 ventilation, setpoint)
    plenum_program = ProgramType('Plenum Program')

    office_avg = ProgramType.average('Office Average Program',
                                     [office_program, plenum_program])

    assert office_avg.people.people_per_area == pytest.approx(0.025, rel=1e-3)
    assert office_avg.people.occupancy_schedule.default_day_schedule.values == \
        office_program.people.occupancy_schedule.default_day_schedule.values
    assert office_avg.people.latent_fraction == \
        office_program.people.latent_fraction
    assert office_avg.people.radiant_fraction == \
        office_program.people.radiant_fraction

    assert office_avg.lighting.watts_per_area == pytest.approx(5, rel=1e-3)
    assert office_avg.lighting.schedule.default_day_schedule.values == \
        office_program.lighting.schedule.default_day_schedule.values
    assert office_avg.lighting.return_air_fraction == \
        office_program.lighting.return_air_fraction
    assert office_avg.lighting.radiant_fraction == \
        office_program.lighting.radiant_fraction
    assert office_avg.lighting.visible_fraction == \
        office_program.lighting.visible_fraction

    assert office_avg.electric_equipment.watts_per_area == pytest.approx(
        5, rel=1e-3)
    assert office_avg.electric_equipment.schedule.default_day_schedule.values == \
        office_program.electric_equipment.schedule.default_day_schedule.values
    assert office_avg.electric_equipment.radiant_fraction == \
        office_program.electric_equipment.radiant_fraction
    assert office_avg.electric_equipment.latent_fraction == \
        office_program.electric_equipment.latent_fraction
    assert office_avg.electric_equipment.lost_fraction == \
        office_program.electric_equipment.lost_fraction

    assert office_avg.gas_equipment is None

    assert office_avg.infiltration.flow_per_exterior_area == \
        pytest.approx(0.0001, rel=1e-3)
    assert office_avg.infiltration.schedule.default_day_schedule.values == \
        office_program.infiltration.schedule.default_day_schedule.values
    assert office_avg.infiltration.constant_coefficient == \
        office_program.infiltration.constant_coefficient
    assert office_avg.infiltration.temperature_coefficient == \
        office_program.infiltration.temperature_coefficient
    assert office_avg.infiltration.velocity_coefficient == \
        office_program.infiltration.velocity_coefficient

    assert office_avg.ventilation.flow_per_person == pytest.approx(0.0025,
                                                                   rel=1e-3)
    assert office_avg.ventilation.flow_per_area == pytest.approx(0.00015,
                                                                 rel=1e-3)
    assert office_avg.ventilation.flow_per_zone == pytest.approx(0, rel=1e-3)
    assert office_avg.ventilation.air_changes_per_hour == pytest.approx(
        0, rel=1e-3)
    assert office_avg.ventilation.schedule is None

    assert office_avg.setpoint.heating_setpoint == pytest.approx(21, rel=1e-3)
    assert office_avg.setpoint.cooling_setpoint == pytest.approx(24, rel=1e-3)
Example #16
0
def from_standards_dict(cls, data):
    """Create a ProgramType from an OpenStudio standards gem dictionary.

    Args:
        data: An OpenStudio standards dictionary of a space type in the
            format below.

    .. code-block:: python

        {
        "template": "90.1-2013",
        "building_type": "Office",
        "space_type": "MediumOffice - OpenOffice",
        "lighting_standard": "ASHRAE 90.1-2013",
        "lighting_per_area": 0.98,
        "lighting_per_person": None,
        "additional_lighting_per_area": None,
        "lighting_fraction_to_return_air": 0.0,
        "lighting_fraction_radiant": 0.7,
        "lighting_fraction_visible": 0.2,
        "lighting_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013",
        "ventilation_standard": "ASHRAE 62.1-2007",
        "ventilation_primary_space_type": "Office Buildings",
        "ventilation_secondary_space_type": "Office space",
        "ventilation_per_area": 0.06,
        "ventilation_per_person": 5.0,
        "ventilation_air_changes": None,
        "minimum_total_air_changes": None,
        "occupancy_per_area": 5.25,
        "occupancy_schedule": "OfficeMedium BLDG_OCC_SCH",
        "occupancy_activity_schedule": "OfficeMedium ACTIVITY_SCH",
        "infiltration_per_exterior_area": 0.0446,
        "infiltration_schedule": "OfficeMedium INFIL_SCH_PNNL",
        "gas_equipment_per_area": None,
        "gas_equipment_fraction_latent": None,
        "gas_equipment_fraction_radiant": None,
        "gas_equipment_fraction_lost": None,
        "gas_equipment_schedule": None,
        "electric_equipment_per_area": 0.96,
        "electric_equipment_fraction_latent": 0.0,
        "electric_equipment_fraction_radiant": 0.5,
        "electric_equipment_fraction_lost": 0.0,
        "electric_equipment_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013",
        "heating_setpoint_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM",
        "cooling_setpoint_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM"
        }
    """
    pr_type_identifier = data['space_type']
    people = None
    lighting = None
    electric_equipment = None
    gas_equipment = None
    hot_water = None
    infiltration = None
    ventilation = None
    setpoint = None

    if 'occupancy_schedule' in data and data['occupancy_schedule'] is not None and \
            'occupancy_per_area' in data and data['occupancy_per_area'] != 0:
        occ_sched = sch_lib.schedule_by_identifier(data['occupancy_schedule'])
        act_sched = sch_lib.schedule_by_identifier(
            data['occupancy_activity_schedule'])
        occ_density = data['occupancy_per_area'] / 92.903
        people = People('{}_People'.format(pr_type_identifier), occ_density,
                        occ_sched, act_sched)

    if 'lighting_schedule' in data and data['lighting_schedule'] is not None:
        light_sched = sch_lib.schedule_by_identifier(data['lighting_schedule'])
        try:
            lpd = data['lighting_per_area'] * 10.7639
        except (TypeError, KeyError):
            lpd = 0  # there's a schedule but no actual load object
        try:
            raf = data['lighting_fraction_to_return_air']
        except KeyError:
            raf = 0
        try:
            lfr = data['lighting_fraction_radiant']
        except KeyError:
            lfr = 0.32
        try:
            lfv = data['lighting_fraction_visible']
        except KeyError:
            lfv = 0.25
        lighting = Lighting('{}_Lighting'.format(pr_type_identifier), lpd,
                            light_sched, raf, lfr, lfv)
        lighting.baseline_watts_per_area = lpd

    if 'electric_equipment_schedule' in data and \
            data['electric_equipment_schedule'] is not None:
        eequip_sched = sch_lib.schedule_by_identifier(
            data['electric_equipment_schedule'])
        try:
            eepd = data['electric_equipment_per_area'] * 10.7639
        except KeyError:
            eepd = 0  # there's a schedule but no actual load object
        electric_equipment = ElectricEquipment(
            '{}_Electric'.format(pr_type_identifier), eepd, eequip_sched,
            data['electric_equipment_fraction_radiant'],
            data['electric_equipment_fraction_latent'],
            data['electric_equipment_fraction_lost'])

    if 'gas_equipment_schedule' in data and \
            data['gas_equipment_schedule'] is not None:
        gequip_sched = sch_lib.schedule_by_identifier(
            data['gas_equipment_schedule'])
        try:
            gepd = data['gas_equipment_per_area'] * 3.15459
        except (TypeError, KeyError):
            gepd = 0  # there's a schedule but no actual load object
        gas_equipment = GasEquipment('{}_Gas'.format(pr_type_identifier), gepd,
                                     gequip_sched,
                                     data['gas_equipment_fraction_radiant'],
                                     data['gas_equipment_fraction_latent'],
                                     data['gas_equipment_fraction_lost'])

    if 'service_water_heating_schedule' in data and \
            data['service_water_heating_schedule'] is not None:
        shw_sch = sch_lib.schedule_by_identifier(
            data['service_water_heating_schedule'])
        try:
            shw_load = data[
                'service_water_heating_peak_flow_per_area'] * 40.7458
        except (TypeError, KeyError):
            shw_load = 0  # there's a schedule but no actual load object
        try:
            shw_temp = round(
                (data['service_water_heating_target_temperature'] - 32.) * 5. /
                9.)
        except (TypeError, KeyError):
            shw_temp = 60
        try:
            fs = data['service_water_heating_fraction_sensible']
        except (TypeError, KeyError):
            fs = 0.2
        try:
            fl = data['service_water_heating_fraction_latent']
        except (TypeError, KeyError):
            fl = 0.05
        hot_water = ServiceHotWater('{}_SHW'.format(pr_type_identifier),
                                    shw_load, shw_sch, shw_temp, fs, fl)

    if 'infiltration_schedule' in data and \
            data['infiltration_schedule'] is not None:
        inf_sched = sch_lib.schedule_by_identifier(
            data['infiltration_schedule'])
        try:
            inf = data['infiltration_per_exterior_area'] * 0.00508
        except KeyError:  # might be using infiltration_per_exterior_wall_area
            try:
                inf = data['infiltration_per_exterior_wall_area'] * 0.00508
            except KeyError:
                inf = 0  # there's a schedule but no actual load object
        infiltration = Infiltration(
            '{}_Infiltration'.format(pr_type_identifier), inf, inf_sched)

    if 'ventilation_standard' in data and \
            data['ventilation_standard'] is not None:
        person = data['ventilation_per_person'] * 0.000471947 if \
            'ventilation_per_person' in data and \
            data['ventilation_per_person'] is not None else 0
        area = data['ventilation_per_area'] * 0.00508 if \
            'ventilation_per_area' in data and \
            data['ventilation_per_area'] is not None else 0
        ach = data['ventilation_air_changes'] if \
            'ventilation_air_changes' in data and \
            data['ventilation_air_changes'] is not None else 0
        ventilation = Ventilation('{}_Ventilation'.format(pr_type_identifier),
                                  person, area, 0, ach)

    if 'heating_setpoint_schedule' in data and \
            data['heating_setpoint_schedule'] is not None:
        heat_sched = sch_lib.schedule_by_identifier(
            data['heating_setpoint_schedule'])
        cool_sched = sch_lib.schedule_by_identifier(
            data['cooling_setpoint_schedule'])
        setpoint = Setpoint('{}_Setpoint'.format(pr_type_identifier),
                            heat_sched, cool_sched)

    return cls(data['space_type'], people, lighting, electric_equipment,
               gas_equipment, hot_water, infiltration, ventilation, setpoint)
Example #17
0
    from honeybee.typing import clean_and_id_ep_string, clean_ep_string
except ImportError as e:
    raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e))

try:
    from honeybee_energy.load.infiltration import Infiltration
    from honeybee_energy.lib.schedules import schedule_by_identifier
except ImportError as e:
    raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e))

try:
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    # make a default Infiltration name if none is provided
    name = clean_and_id_ep_string('Infiltration') if _name_ is None else \
        clean_ep_string(_name_)

    # get the schedule
    _schedule_ = _schedule_ if _schedule_ is not None else 'Always On'
    if isinstance(_schedule_, str):
        _schedule_ = schedule_by_identifier(_schedule_)

    # create the Infiltration object
    infil = Infiltration(name, _flow_per_ext_area, _schedule_)
    if _name_ is not None:
        infil.display_name = _name_
Example #18
0
    plenum_program = ProgramType('Plenum')
    plenum_program.lock()
    _json_program_types['Plenum'] = plenum_program

try:
    office_program = _json_program_types['Generic Office Program']
except KeyError:
    if _s.generic_office_occupancy is not None:
        people = People('Generic Office People', 0.0565,
                        _s.generic_office_occupancy,
                        _s.generic_office_activity)
        lighting = Lighting('Generic Office Lighting', 10.55,
                            _s.generic_office_lighting, 0.0, 0.7, 0.2)
        equipment = ElectricEquipment('Generic Office Equipment', 10.33,
                                      _s.generic_office_equipment, 0.5)
        infiltration = Infiltration('Generic Office Infiltration', 0.0002266,
                                    _s.generic_office_infiltration)
        ventilation = Ventilation('Generic Office Ventilation', 0.00236,
                                  0.000305)
        setpoint = Setpoint('Generic Office Setpoints',
                            _s.generic_office_heating,
                            _s.generic_office_cooling)
        office_program = ProgramType('Generic Office Program', people,
                                     lighting, equipment, None, infiltration,
                                     ventilation, setpoint)
        plenum_program.lock()
    else:
        office_program = None
    _json_program_types['Generic Office Program'] = office_program

# make lists of program types to look up items in the library
PROGRAM_TYPES = tuple(_json_program_types.keys())