Beispiel #1
0
def test_ventilation_lockability():
    """Test the lockability of Ventilation objects."""
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)

    ventilation.flow_per_person = 0.01
    ventilation.lock()
    with pytest.raises(AttributeError):
        ventilation.flow_per_person = 0.0025
    ventilation.unlock()
    ventilation.flow_per_person = 0.0025
Beispiel #2
0
def test_ventilation_init_from_idf():
    """Test the initialization of Ventilation from_idf."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Ventilation Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)
    ventilation.schedule = schedule
    sched_dict = {schedule.name: schedule}

    idf_str = ventilation.to_idf('Test Zone')
    rebuilt_ventilation = Ventilation.from_idf(idf_str, sched_dict)
    assert ventilation == rebuilt_ventilation
Beispiel #3
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))
Beispiel #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
Beispiel #5
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_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
Beispiel #7
0
def test_ventilation_init():
    """Test the initialization of Ventilation and basic properties."""
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)
    str(ventilation)  # test the string representation

    assert ventilation.name == 'Office Ventilation'
    assert ventilation.flow_per_person == 0.0025
    assert ventilation.flow_per_area == 0.0006
    assert ventilation.flow_per_zone == 0
    assert ventilation.air_changes_per_hour == 0
    assert ventilation.schedule is None
Beispiel #8
0
def test_ventilation_average():
    """Test the Ventilation.average method."""
    weekday_office = ScheduleDay(
        'Weekday Office Ventilation', [0, 1, 0.5, 0],
        [Time(0, 0), Time(9, 0),
         Time(17, 0), Time(19, 0)])
    weekday_lobby = ScheduleDay(
        'Weekday Lobby Ventilation', [0.1, 1, 0.1],
        [Time(0, 0), Time(8, 0), Time(20, 0)])
    weekend_office = ScheduleDay('Weekend Office Ventilation', [0])
    weekend_lobby = ScheduleDay('Weekend Office Ventilation', [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 Ventilation', weekday_office,
                                      [wknd_office_rule],
                                      schedule_types.fractional)
    lobby_schedule = ScheduleRuleset('Lobby Ventilation', weekday_lobby,
                                     [wknd_lobby_rule],
                                     schedule_types.fractional)

    office_vent = Ventilation('Office Ventilation', 0.01, 0.0006, 0, 0,
                              office_schedule)
    lobby_vent = Ventilation('Lobby Ventilation', 0, 0, 0, 1, lobby_schedule)

    office_avg = Ventilation.average('Average Ventilation',
                                     [office_vent, lobby_vent])

    assert office_avg.flow_per_person == pytest.approx(0.005, rel=1e-3)
    assert office_avg.flow_per_area == pytest.approx(0.0003, rel=1e-3)
    assert office_avg.flow_per_zone == pytest.approx(0, rel=1e-3)
    assert office_avg.air_changes_per_hour == pytest.approx(0.5, 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

    office_vent.schedule = None
    lobby_vent.schedule = None
    office_avg = Ventilation.average('Average Ventilation',
                                     [office_vent, lobby_vent])

    assert office_avg.schedule is None
Beispiel #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
Beispiel #10
0
def test_ventilation_init_schedule():
    """Test the initialization of Ventilation with a schedule."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Ventilation Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006, 0, 0,
                              schedule)
    str(ventilation)  # test the string representation

    assert ventilation.name == 'Office Ventilation'
    assert ventilation.flow_per_person == 0.0025
    assert ventilation.flow_per_area == 0.0006
    assert ventilation.flow_per_zone == 0
    assert ventilation.air_changes_per_hour == 0
    assert ventilation.schedule.name == 'Office Ventilation Schedule'
    assert ventilation.schedule.schedule_type_limit == schedule_types.fractional
    assert ventilation.schedule == schedule
Beispiel #11
0
def test_ventilation_setability():
    """Test the setting of properties of Ventilation."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Ventilation Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)

    ventilation.name = 'Office Zone Ventilation'
    assert ventilation.name == 'Office Zone Ventilation'
    ventilation.flow_per_person = 0.01
    assert ventilation.flow_per_person == 0.01
    ventilation.flow_per_area = 0
    assert ventilation.flow_per_area == 0
    ventilation.flow_per_zone = 1
    assert ventilation.flow_per_zone == 1
    ventilation.air_changes_per_hour = 2
    assert ventilation.air_changes_per_hour == 2
    ventilation.schedule = schedule
    assert ventilation.schedule == schedule
Beispiel #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
Beispiel #13
0
def test_ventilation_dict_methods():
    """Test the to/from dict methods."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Ventilation Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)

    vent_dict = ventilation.to_dict()
    new_ventilation = Ventilation.from_dict(vent_dict)
    assert new_ventilation == ventilation
    assert vent_dict == new_ventilation.to_dict()

    ventilation.schedule = schedule
    vent_dict = ventilation.to_dict()
    new_ventilation = Ventilation.from_dict(vent_dict)
    assert new_ventilation == ventilation
    assert vent_dict == new_ventilation.to_dict()
Beispiel #14
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
Beispiel #15
0
def test_ventilation_equality():
    """Test the equality of Ventilation objects."""
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Ventilation Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = Ventilation('Office Ventilation', 0.0025, 0.0006)
    ventilation_dup = ventilation.duplicate()
    ventilation_alt = Ventilation('Office Ventilation', 0.0025, 0.0006)
    ventilation_alt.schedule = schedule

    assert ventilation is ventilation
    assert ventilation is not ventilation_dup
    assert ventilation == ventilation_dup
    ventilation_dup.flow_per_person = 0.01
    assert ventilation != ventilation_dup
    assert ventilation != ventilation_alt
Beispiel #16
0
    _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())

try:
    from honeybee_energy.load.ventilation import Ventilation
    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))

# make a default Ventilation name if none is provided
name = clean_and_id_ep_string('Ventilation') if _name_ is None else \
    clean_ep_string(_name_)

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

# get default _flow_per_person_, _flow_per_area_, and _ach_
_flow_per_person_ = _flow_per_person_ if _flow_per_person_ is not None else 0.0
_flow_per_area_ = _flow_per_area_ if _flow_per_area_ is not None else 0.0
_flow_per_zone_ = _flow_per_zone_ if _flow_per_zone_ is not None else 0.0
_ach_ = _ach_ if _ach_ is not None else 0.0

# create the Ventilation object
vent = Ventilation(name, _flow_per_person_, _flow_per_area_, _flow_per_zone_,
                   _ach_, _schedule_)
if _name_ is not None:
    vent.display_name = _name_
Beispiel #18
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)
Beispiel #19
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)
Beispiel #20
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)