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
def test_equipment_lockability():
    """Test the lockability 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.watts_per_area = 6
    equipment.lock()
    with pytest.raises(AttributeError):
        equipment.watts_per_area = 8
    with pytest.raises(AttributeError):
        equipment.schedule.default_day_schedule.remove_value_by_time(
            Time(17, 0))
    equipment.unlock()
    equipment.watts_per_area = 8
    with pytest.raises(AttributeError):
        equipment.schedule.default_day_schedule.remove_value_by_time(
            Time(17, 0))
def test_set_loads():
    """Test the setting of a load objects on a Room."""
    lab_equip_day = ScheduleDay('Daily Lab Equipment', [0.25, 0.5, 0.25],
                                [Time(0, 0), Time(9, 0), Time(20, 0)])
    lab_equipment = ScheduleRuleset('Lab Equipment', lab_equip_day,
                                    None, schedule_types.fractional)
    lab_vent_day = ScheduleDay('Daily Lab Ventilation', [0.5, 1, 0.5],
                               [Time(0, 0), Time(9, 0), Time(20, 0)])
    lab_ventilation = ScheduleRuleset('Lab Ventilation', lab_vent_day,
                                      None, schedule_types.fractional)

    room = Room.from_box('BioLaboratoryZone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    lab_equip = ElectricEquipment('Lab Equipment', 50, lab_equipment)
    lav_vent = Ventilation('Lab Ventilation', 0, 0, 0, 6, lab_ventilation)
    lab_setpt = room.properties.energy.setpoint.duplicate()
    lab_setpt.heating_setpoint = 22
    lab_setpt.cooling_setpoint = 24
    room.properties.energy.electric_equipment = lab_equip
    room.properties.energy.ventilation = lav_vent
    room.properties.energy.setpoint = lab_setpt

    assert room.properties.energy.program_type == office_program
    assert room.properties.energy.electric_equipment.watts_per_area == 50
    assert room.properties.energy.electric_equipment.schedule == lab_equipment
    assert room.properties.energy.ventilation.flow_per_person == 0
    assert room.properties.energy.ventilation.flow_per_area == 0
    assert room.properties.energy.ventilation.air_changes_per_hour == 6
    assert room.properties.energy.ventilation.schedule == lab_ventilation
    assert room.properties.energy.setpoint.heating_setpoint == 22
    assert room.properties.energy.setpoint.heating_setback == 22
    assert room.properties.energy.setpoint.cooling_setpoint == 24
    assert room.properties.energy.setpoint.cooling_setback == 24
Example #4
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 #5
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 #6
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()
def test_equipment_dict_methods():
    """Test the to/from dict methods."""
    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)

    equip_dict = equipment.to_dict()
    new_equipment = ElectricEquipment.from_dict(equip_dict)
    assert new_equipment == equipment
    assert equip_dict == new_equipment.to_dict()
def test_equipment_average():
    """Test the ElectricEquipment.average method."""
    weekday_office = ScheduleDay(
        'Weekday Office Equip', [0, 1, 0.5, 0],
        [Time(0, 0), Time(9, 0),
         Time(17, 0), Time(19, 0)])
    weekday_lobby = ScheduleDay(
        'Weekday Lobby Equip', [0.1, 1, 0.1],
        [Time(0, 0), Time(8, 0), Time(20, 0)])
    weekend_office = ScheduleDay('Weekend Office Equip', [0])
    weekend_lobby = ScheduleDay('Weekend Office Equip', [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 Equip', weekday_office,
                                      [wknd_office_rule],
                                      schedule_types.fractional)
    lobby_schedule = ScheduleRuleset('Lobby Equip', weekday_lobby,
                                     [wknd_lobby_rule],
                                     schedule_types.fractional)

    office_equip = ElectricEquipment('Office Equip', 10, office_schedule, 0.3,
                                     0.3)
    lobby_equip = ElectricEquipment('Lobby Equip', 6, lobby_schedule, 0.4, 0.2,
                                    0.1)

    office_avg = ElectricEquipment.average('Office Average Equip',
                                           [office_equip, lobby_equip])

    assert office_avg.watts_per_area == pytest.approx(8, rel=1e-3)
    assert office_avg.radiant_fraction == pytest.approx(0.35, rel=1e-3)
    assert office_avg.latent_fraction == pytest.approx(0.25, rel=1e-3)
    assert office_avg.lost_fraction == 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
def test_equipment_init_from_idf():
    """Test the initialization of ElectricEquipment from_idf."""
    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)
    sched_dict = {schedule.name: schedule}

    zone_name = 'Test Zone'
    idf_str = equipment.to_idf(zone_name)
    rebuilt_equipment, rebuilt_zone_name = ElectricEquipment.from_idf(
        idf_str, sched_dict)
    assert equipment == rebuilt_equipment
    assert zone_name == rebuilt_zone_name
Example #10
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
def test_equipment_init():
    """Test the initialization of ElectricEquipment and basic properties."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Equip', simple_office, None,
                               schedule_types.fractional)
    equipment = ElectricEquipment('Open Office Zone Equip', 8, schedule)
    str(equipment)  # test the string representation

    assert equipment.name == 'Open Office Zone Equip'
    assert equipment.watts_per_area == 8
    assert equipment.schedule.name == 'Office Equip'
    assert equipment.schedule.schedule_type_limit == schedule_types.fractional
    assert equipment.schedule == schedule
    assert equipment.radiant_fraction == 0
    assert equipment.latent_fraction == 0
    assert equipment.lost_fraction == 0
    assert equipment.convected_fraction == 1
Example #12
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 #13
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
def test_equipment_setability():
    """Test the setting of properties of ElectricEquipment."""
    simple_office = ScheduleDay(
        'Simple Weekday Equip', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Equip', simple_office, None,
                               schedule_types.fractional)
    constant = ScheduleRuleset.from_constant_value('Constant Equip', 1,
                                                   schedule_types.fractional)
    equipment = ElectricEquipment('Open Office Zone Equip', 8, schedule)

    equipment.name = 'Office Zone Equip'
    assert equipment.name == 'Office Zone Equip'
    equipment.watts_per_area = 6
    assert equipment.watts_per_area == 6
    equipment.schedule = constant
    assert equipment.schedule == constant
    assert equipment.schedule.values() == [1] * 8760
    equipment.radiant_fraction = 0.4
    assert equipment.radiant_fraction == 0.4
    equipment.latent_fraction = 0.2
    assert equipment.latent_fraction == 0.2
    equipment.lost_fraction = 0.1
    assert equipment.lost_fraction == 0.1
Example #15
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 #16
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 #17
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 #18
0
    plenum_program = _json_program_types['Plenum']
except KeyError:
    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
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 Equipment name if none is provided
    if _name_ is None:
        name = "Equipment_{}".format(uuid.uuid4())
    else:
        name = clean_and_id_ep_string(_name_)

    # get the schedule
    if isinstance(_schedule, str):
        _schedule = schedule_by_identifier(_schedule)

    # get default radiant, latent, and lost fractions
    radiant_fract_ = radiant_fract_ if radiant_fract_ is not None else 0.0
    latent_fract_ = latent_fract_ if latent_fract_ is not None else 0.0
    lost_fract_ = lost_fract_ if lost_fract_ is not None else 0.0

    # create the Equipment object
    if gas_:
        equip = GasEquipment(name, _watts_per_area, _schedule, radiant_fract_,
                             latent_fract_, lost_fract_)
    else:
        equip = ElectricEquipment(name, _watts_per_area, _schedule,
                                  radiant_fract_, latent_fract_, lost_fract_)
    if _name_ is not None:
        equip.display_name = _name_