Exemplo n.º 1
0
def test_to_from_time_string():
    """Test the from_time_string method for Time."""
    t1 = Time(12, 30)
    t_str = str(t1)
    rebuilt_t = Time.from_time_string(t_str)
    assert rebuilt_t == t1
    assert str(rebuilt_t) == t_str
Exemplo n.º 2
0
def test_time_to_from_array():
    """Test the from_array method for Date."""
    t1 = Time(12, 30)
    t_arr = t1.to_array()
    rebuilt_t = Time.from_array(t_arr)
    assert rebuilt_t == t1
    assert rebuilt_t.to_array() == t_arr
Exemplo n.º 3
0
def test_time_to_from_dict():
    """Test the dict methods for Time."""
    t1 = Time(12, 30)
    t_dict = t1.to_dict()
    rebuilt_t = Time.from_dict(t_dict)
    assert t1 == rebuilt_t
    assert rebuilt_t.to_dict() == t_dict
Exemplo n.º 4
0
def test_people_setability():
    """Test the setting of properties of People."""
    simple_office = ScheduleDay(
        'Simple Weekday Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    occ_schedule = ScheduleRuleset('Office Occupancy', simple_office, None,
                                   schedule_types.fractional)
    constant_ppl = ScheduleRuleset.from_constant_value(
        'Constant Occ', 1, schedule_types.fractional)
    sleeping_act = ScheduleRuleset.from_constant_value(
        'Sleeping Activity', 95, schedule_types.activity_level)
    people = People('Open Office Zone People', 0.05, occ_schedule)

    people.identifier = 'Office Zone People'
    assert people.identifier == 'Office Zone People'
    people.people_per_area = 0.1
    assert people.people_per_area == 0.1
    assert people.area_per_person == 10
    people.area_per_person = 20
    assert people.area_per_person == 20
    assert people.people_per_area == 0.05
    people.occupancy_schedule = constant_ppl
    assert people.occupancy_schedule == constant_ppl
    people.activity_schedule = sleeping_act
    assert people.activity_schedule.schedule_type_limit == schedule_types.activity_level
    assert people.activity_schedule.values() == [95] * 8760
    people.radiant_fraction = 0.4
    assert people.radiant_fraction == 0.4
    people.latent_fraction = 0.2
    assert people.latent_fraction == 0.2
Exemplo n.º 5
0
def test_schedule_rule_from_days_applied():
    """Test the ScheduleRule from_days_applied method."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])

    sched_rule = ScheduleRule.from_days_applied(
        simple_office,
        ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'])
    assert not sched_rule.apply_sunday
    assert sched_rule.apply_monday
    assert sched_rule.apply_tuesday
    assert sched_rule.apply_wednesday
    assert sched_rule.apply_thursday
    assert sched_rule.apply_friday
    assert not sched_rule.apply_saturday
    assert not sched_rule.apply_holiday
    sched_rule = ScheduleRule.from_days_applied(simple_office, ['weekday'])
    assert not sched_rule.apply_sunday
    assert sched_rule.apply_monday
    assert sched_rule.apply_tuesday
    assert sched_rule.apply_wednesday
    assert sched_rule.apply_thursday
    assert sched_rule.apply_friday
    assert not sched_rule.apply_saturday
    assert not sched_rule.apply_holiday
Exemplo n.º 6
0
def test_lighting_setability():
    """Test the setting of properties of Lighting."""
    simple_office = ScheduleDay(
        'Simple Weekday Light', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Lighting', simple_office, None,
                               schedule_types.fractional)
    constant = ScheduleRuleset.from_constant_value('Constant Light', 1,
                                                   schedule_types.fractional)
    lighting = Lighting('Open Office Zone Lighting', 10, schedule)

    lighting.identifier = 'Office Zone Lighting'
    assert lighting.identifier == 'Office Zone Lighting'
    lighting.watts_per_area = 6
    assert lighting.watts_per_area == 6
    lighting.schedule = constant
    assert lighting.schedule == constant
    assert lighting.schedule.values() == [1] * 8760
    lighting.return_air_fraction = 0.1
    assert lighting.return_air_fraction == 0.1
    lighting.radiant_fraction = 0.4
    assert lighting.radiant_fraction == 0.4
    lighting.visible_fraction = 0.2
    assert lighting.visible_fraction == 0.2
    lighting.baseline_watts_per_area = 5.0
    assert lighting.baseline_watts_per_area == 5.0
Exemplo n.º 7
0
def test_schedule_day_data_collection():
    """Test the ScheduleDay data_collection method."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [1, 2, 1, 2, 1],
        [Time(0, 0),
         Time(6, 0),
         Time(12, 0),
         Time(16, 0),
         Time(20, 0)])
    office_data = simple_office.data_collection(Date(6, 21),
                                                schedule_types.fractional)
    hour_vals_from_ep = (1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2,
                         2, 2, 1, 1, 1, 1)

    assert isinstance(office_data, HourlyContinuousCollection)
    assert office_data.values == hour_vals_from_ep
    assert office_data.header.analysis_period == AnalysisPeriod(
        6, 21, 0, 6, 21, 23)
    assert office_data.header.data_type == schedule_types.fractional.data_type
    assert office_data.header.unit == schedule_types.fractional.unit

    # test without type limits or a start date
    office_data2 = simple_office.data_collection()
    assert office_data2.header.analysis_period == AnalysisPeriod(
        1, 1, 0, 1, 1, 23)
    assert isinstance(office_data2.header.data_type, GenericType)
Exemplo n.º 8
0
def test_schedule_day_init_from_idf_hourly():
    """Test the initialization of ScheduleDay from_idf Schedule:Day:Hourly."""
    sched_str = """Schedule:Day:Hourly,
                Simple Office Occupancy, !- Name
                ,                        !- Schedule Type Limits Name
                0,                       !- Hour 1
                0,                       !- Hour 2
                0,                       !- Hour 3
                0,                       !- Hour 4
                0,                       !- Hour 5
                0,                       !- Hour 6
                0,                       !- Hour 7
                0,                       !- Hour 8
                0,                       !- Hour 9
                1,                       !- Hour 10
                1,                       !- Hour 11
                1,                       !- Hour 12
                1,                       !- Hour 13
                1,                       !- Hour 14
                1,                       !- Hour 15
                1,                       !- Hour 16
                1,                       !- Hour 17
                0,                       !- Hour 18
                0,                       !- Hour 19
                0,                       !- Hour 20
                0,                       !- Hour 21
                0,                       !- Hour 22
                0,                       !- Hour 23
                0;                       !- Hour 24
                """
    test_sched = ScheduleDay.from_idf(sched_str)
    simple_office = ScheduleDay('Simple Office Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])

    assert test_sched == simple_office
Exemplo n.º 9
0
def test_schedule_rule_apply_day_by_name():
    """Test the ScheduleRule apply_day_by_name properties."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sched_rule = ScheduleRule(simple_office)

    assert not sched_rule.apply_sunday
    sched_rule.apply_day_by_name('Sunday')
    assert sched_rule.apply_sunday
    assert not sched_rule.apply_monday
    sched_rule.apply_day_by_name('Monday')
    assert sched_rule.apply_monday
    assert not sched_rule.apply_tuesday
    sched_rule.apply_day_by_name('Tuesday')
    assert sched_rule.apply_tuesday
    assert not sched_rule.apply_wednesday
    sched_rule.apply_day_by_name('Wednesday')
    assert sched_rule.apply_wednesday
    assert not sched_rule.apply_thursday
    sched_rule.apply_day_by_name('Thursday')
    assert sched_rule.apply_thursday
    assert not sched_rule.apply_friday
    sched_rule.apply_day_by_name('Friday')
    assert sched_rule.apply_friday
    assert not sched_rule.apply_saturday
    sched_rule.apply_day_by_name('Saturday')
    assert sched_rule.apply_saturday
    assert not sched_rule.apply_holiday
    sched_rule.apply_day_by_name('Holiday')
    assert sched_rule.apply_holiday

    assert sched_rule.apply_weekday
    assert sched_rule.apply_weekend
    assert sched_rule.apply_all
Exemplo n.º 10
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
Exemplo n.º 11
0
def test_schedule_rule_apply_day_by_dow():
    """Test the ScheduleRule apply_day_by_dow properties."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sched_rule = ScheduleRule(simple_office)

    assert not sched_rule.apply_sunday
    sched_rule.apply_day_by_dow(1)
    assert sched_rule.apply_sunday
    assert not sched_rule.apply_monday
    sched_rule.apply_day_by_dow(2)
    assert sched_rule.apply_monday
    assert not sched_rule.apply_tuesday
    sched_rule.apply_day_by_dow(3)
    assert sched_rule.apply_tuesday
    assert not sched_rule.apply_wednesday
    sched_rule.apply_day_by_dow(4)
    assert sched_rule.apply_wednesday
    assert not sched_rule.apply_thursday
    sched_rule.apply_day_by_dow(5)
    assert sched_rule.apply_thursday
    assert not sched_rule.apply_friday
    sched_rule.apply_day_by_dow(6)
    assert sched_rule.apply_friday
    assert not sched_rule.apply_saturday
    sched_rule.apply_day_by_dow(7)
    assert sched_rule.apply_saturday
    assert not sched_rule.apply_holiday
    sched_rule.apply_day_by_dow(8)
    assert sched_rule.apply_holiday

    assert sched_rule.apply_weekday
    assert sched_rule.apply_weekend
    assert sched_rule.apply_all
Exemplo n.º 12
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_ideal_air_to_dict():
    """Test the to_dict method."""
    ideal_air = IdealAirSystem('Passive House HVAC System')

    ideal_air.economizer_type = 'DifferentialEnthalpy'
    ideal_air.demand_controlled_ventilation = True
    ideal_air.sensible_heat_recovery = 0.75
    ideal_air.latent_heat_recovery = 0.6
    ideal_air.heating_air_temperature = 40
    ideal_air.cooling_air_temperature = 15
    ideal_air.heating_limit = 2000
    ideal_air.cooling_limit = 3500
    sch_day = ScheduleDay(
        'Day Control', [0, 1, 0],
        [Time(0, 0), Time(8, 0), Time(22, 0)])
    schedule = ScheduleRuleset('HVAC Control', sch_day, None,
                               schedule_types.on_off)
    ideal_air.heating_availability = schedule
    ideal_air.cooling_availability = schedule

    ideal_air_dict = ideal_air.to_dict(abridged=True)

    assert ideal_air_dict['economizer_type'] == 'DifferentialEnthalpy'
    assert ideal_air_dict['demand_controlled_ventilation'] == True
    assert ideal_air_dict['sensible_heat_recovery'] == 0.75
    assert ideal_air_dict['latent_heat_recovery'] == 0.6
    assert ideal_air_dict['heating_air_temperature'] == 40
    assert ideal_air_dict['cooling_air_temperature'] == 15
    assert ideal_air_dict['heating_limit'] == 2000
    assert ideal_air_dict['cooling_limit'] == 3500
    assert ideal_air_dict['heating_availability'] == 'HVAC Control'
    assert ideal_air_dict['cooling_availability'] == 'HVAC Control'
def test_ideal_air_system_setability():
    """Test the setting of properties of IdealAirSystem."""
    ideal_air = IdealAirSystem('Test System')

    ideal_air.identifier = 'Test System2'
    assert ideal_air.identifier == 'Test System2'
    ideal_air.economizer_type = 'DifferentialEnthalpy'
    assert ideal_air.economizer_type == 'DifferentialEnthalpy'
    ideal_air.sensible_heat_recovery = 0.75
    assert ideal_air.sensible_heat_recovery == 0.75
    ideal_air.latent_heat_recovery = 0.65
    assert ideal_air.latent_heat_recovery == 0.65
    ideal_air.heating_air_temperature = 40
    assert ideal_air.heating_air_temperature == 40
    ideal_air.cooling_air_temperature = 15
    assert ideal_air.cooling_air_temperature == 15
    ideal_air.heating_limit = 1000
    assert ideal_air.heating_limit == 1000
    ideal_air.cooling_limit = 2000
    assert ideal_air.cooling_limit == 2000

    sch_day = ScheduleDay(
        'Day Control', [0, 1, 0],
        [Time(0, 0), Time(8, 0), Time(22, 0)])
    schedule = ScheduleRuleset('HVAC Control', sch_day, None,
                               schedule_types.on_off)
    ideal_air.heating_availability = schedule
    assert ideal_air.heating_availability == schedule
    ideal_air.cooling_availability = schedule
    assert ideal_air.cooling_availability == schedule
Exemplo n.º 15
0
def schedule_primary_school_occupancy(directory):
    weekday_school = ScheduleDay('Weekday School Year', [0, 1, 0.5, 0],
                                 [Time(0, 0), Time(8, 0), Time(15, 0), Time(18, 0)])
    weekend_school = ScheduleDay('Weekend School Year', [0])
    weekday_summer = ScheduleDay('Weekday Summer', [0, 0.5, 0],
                                 [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_summer = ScheduleDay('Weekend Summer', [0])

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

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

    schedule = ScheduleRuleset('School Occupancy', weekday_school,
                               [summer_weekday_rule, summer_weekend_rule,
                                school_weekend_rule], schedule_types.fractional,
                                weekend_summer, summer_design, winter_design)

    dest_file = os.path.join(directory, 'schedule_primary_school_occupancy.json')
    with open(dest_file, 'w') as fp:
        json.dump(schedule.to_dict(True), fp, indent=4)
Exemplo n.º 16
0
def test_schedule_day_values_at_timestep_interpolate():
    """Test the ScheduleDay values_at_timestep method."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [1, 2, 1, 2, 1],
        [Time(0, 0),
         Time(6, 0),
         Time(12, 0),
         Time(16, 0),
         Time(20, 0)])
    simple_office.interpolate = True
    hourly_vals = simple_office.values_at_timestep()
    half_hour_vals = simple_office.values_at_timestep(2)

    hourly_vals_from_ep = [
        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.166667, 1.333333, 1.5, 1.666667,
        1.833333, 2.0, 1.75, 1.5, 1.25, 1.0, 1.25, 1.5, 1.75, 2.0, 1.75, 1.5,
        1.25, 1.0
    ]
    vals_from_ep = [
        1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.083333,
        1.166667, 1.25, 1.333333, 1.416667, 1.5, 1.583333, 1.666667, 1.75,
        1.833333, 1.916667, 2.0, 1.875, 1.75, 1.625, 1.5, 1.375, 1.25, 1.125,
        1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2.0, 1.875, 1.75,
        1.625, 1.5, 1.375, 1.25, 1.125, 1.0
    ]

    for hb_val, ep_val in zip(hourly_vals, hourly_vals_from_ep):
        assert hb_val == pytest.approx(ep_val, rel=1e-3)
    for hb_val, ep_val in zip(half_hour_vals, vals_from_ep):
        assert hb_val == pytest.approx(ep_val, rel=1e-3)
Exemplo n.º 17
0
def test_schedule_rule_apply():
    """Test the ScheduleRule apply properties."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sched_rule = ScheduleRule(simple_office)

    assert not sched_rule.apply_sunday
    sched_rule.apply_sunday = True
    assert sched_rule.apply_sunday
    assert not sched_rule.apply_monday
    sched_rule.apply_monday = True
    assert sched_rule.apply_monday
    assert not sched_rule.apply_tuesday
    sched_rule.apply_tuesday = True
    assert sched_rule.apply_tuesday
    assert not sched_rule.apply_wednesday
    sched_rule.apply_wednesday = True
    assert sched_rule.apply_wednesday
    assert not sched_rule.apply_thursday
    sched_rule.apply_thursday = True
    assert sched_rule.apply_thursday
    assert not sched_rule.apply_friday
    sched_rule.apply_friday = True
    assert sched_rule.apply_friday
    assert not sched_rule.apply_saturday
    sched_rule.apply_saturday = True
    assert sched_rule.apply_saturday

    assert sched_rule.apply_weekday
    assert sched_rule.apply_weekend
    assert sched_rule.apply_all
Exemplo n.º 18
0
def test_schedule_day_dict_methods():
    """Test the to/from dict methods."""
    simple_office = ScheduleDay('Simple Office Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])
    sch_dict = simple_office.to_dict()
    new_simple_office = ScheduleDay.from_dict(sch_dict)
    assert new_simple_office == simple_office
    assert sch_dict == new_simple_office.to_dict()
Exemplo n.º 19
0
def test_schedule_day_init_from_values_at_timestep():
    """Test the initialization of ScheduleDay from_values_at_timestep."""
    simple_office = ScheduleDay('Simple Office Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])
    half_hour_vals = simple_office.values_at_timestep(2)
    test_sched = ScheduleDay.from_values_at_timestep('Simple Office Occupancy',
                                                     half_hour_vals, 2)

    assert test_sched == simple_office
Exemplo n.º 20
0
def test_schedule_ruleset_init():
    """Test the ScheduleRuleset initialization and basic properties."""
    weekday_office = ScheduleDay(
        'Weekday Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Occupancy', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sunday_office = ScheduleDay('Sunday Office Occupancy', [0])
    sat_rule = ScheduleRule(saturday_office, apply_saturday=True)
    sun_rule = ScheduleRule(sunday_office, apply_sunday=True)
    summer_office = ScheduleDay(
        'Summer Office Occupancy', [0, 1, 0.25],
        [Time(0, 0), Time(6, 0), Time(22, 0)])
    winter_office = ScheduleDay('Winter Office Occupancy', [0])
    schedule = ScheduleRuleset('Office Occupancy', weekday_office,
                               [sat_rule, sun_rule], schedule_types.fractional,
                               summer_office, winter_office)
    str(schedule)  # test the string representation

    assert schedule.name == 'Office Occupancy'
    assert schedule.default_day_schedule == weekday_office
    assert schedule.summer_designday_schedule == summer_office
    assert schedule.winter_designday_schedule == winter_office
    assert schedule.schedule_type_limit == schedule_types.fractional
    assert len(schedule.schedule_rules) == 2

    schedule.remove_rule(1)
    assert len(schedule.schedule_rules) == 1
    schedule.add_rule(sun_rule)
    assert len(schedule.schedule_rules) == 2

    with pytest.raises(ValueError):
        schedule = ScheduleRuleset('Office Occupancy', weekday_office)
Exemplo n.º 21
0
def test_schedule_ruleset_to_from_idf():
    """Test the ScheduleRuleset to_idf and from_idf methods."""
    weekday_office = ScheduleDay(
        'Weekday Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Occupancy', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sunday_office = ScheduleDay('Sunday Office Occupancy', [0])
    week_rule = ScheduleRule(weekday_office)
    week_rule.apply_weekday = True
    sat_rule = ScheduleRule(saturday_office, apply_saturday=True)
    summer_office = ScheduleDay(
        'Summer Office Occupancy', [0, 1, 0.25],
        [Time(0, 0), Time(6, 0), Time(22, 0)])
    winter_office = ScheduleDay('Winter Office Occupancy', [0])
    schedule = ScheduleRuleset('Office Occupancy', sunday_office,
                               [week_rule, sat_rule],
                               schedule_types.fractional, summer_office,
                               winter_office)

    year_sched, week_scheds = schedule.to_idf()
    assert len(week_scheds) == 1

    day_scheds = (weekday_office.to_idf(), saturday_office.to_idf(),
                  sunday_office.to_idf(), summer_office.to_idf(),
                  winter_office.to_idf())
    sch_type = schedule_types.fractional.to_idf()

    rebuilt_schedule = ScheduleRuleset.from_idf(year_sched, week_scheds,
                                                day_scheds, sch_type)
    rebuilt_year_sched, rebuilt_week_scheds = rebuilt_schedule.to_idf()

    assert rebuilt_year_sched == year_sched
    assert rebuilt_week_scheds[0] == week_scheds[0]
Exemplo n.º 22
0
def test_schedule_day_equality():
    """Test the equality of ScheduleDay objects."""
    simple_office = ScheduleDay('Simple Office Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])
    office_dup = simple_office.duplicate()
    sunday_office = ScheduleDay('Sunday Office Occupancy', [0])

    assert simple_office is simple_office
    assert simple_office is not office_dup
    assert simple_office == office_dup
    assert simple_office != sunday_office
Exemplo n.º 23
0
def ventilation_control_detailed(directory):
    simple_flush = ScheduleDay('Simple Flush', [1, 0, 1],
                               [Time(0, 0), Time(9, 0), Time(22, 0)])
    schedule = ScheduleRuleset('Night Flush Schedule', simple_flush,
                               None, schedule_types.fractional)
    ventilation = VentilationControl(22, 28, 12, 32, 0)
    ventilation.schedule = schedule

    dest_file = os.path.join(directory, 'ventilation_control_detailed.json')
    with open(dest_file, 'w') as fp:
        json.dump(ventilation.to_dict(abridged=True), fp, indent=4)
Exemplo n.º 24
0
def test_schedule_day_dict_methods():
    """Test the to/from dict methods."""
    simple_office = ScheduleDay(
        'Simple Office Occupancy', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    sched_rule = ScheduleRule(simple_office)
    sched_rule.apply_weekday = True

    rule_dict = sched_rule.to_dict()
    new_sched_rule = ScheduleRule.from_dict(rule_dict)
    assert new_sched_rule == sched_rule
    assert rule_dict == new_sched_rule.to_dict()
Exemplo n.º 25
0
def program_type_office(directory):
    dest_file = os.path.join(directory, 'program_type_office.json')
    program_obj = office_program.duplicate()
    simple_office = ScheduleDay(
        'Simple Weekday', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    schedule = ScheduleRuleset('Office Water Use', simple_office, None,
                               schedule_types.fractional)
    shw = ServiceHotWater('Office Hot Water', 0.1, schedule)
    program_obj.service_hot_water = shw
    with open(dest_file, 'w') as fp:
        json.dump(program_obj.to_dict(abridged=False), fp, indent=4)
Exemplo n.º 26
0
def test_ventilation_control_init_schedule():
    """Test the initialization of VentilationControl with a schedule."""
    simple_office = ScheduleDay('Simple Flush', [1, 0, 1],
                                [Time(0, 0), Time(9, 0), Time(22, 0)])
    schedule = ScheduleRuleset('Night Flush Schedule', simple_office,
                               None, schedule_types.fractional)
    ventilation = VentilationControl(100, schedule=schedule)
    str(ventilation)  # test the string representation

    assert ventilation.min_indoor_temperature == 100
    assert ventilation.schedule.identifier == 'Night Flush Schedule'
    assert ventilation.schedule.schedule_type_limit == schedule_types.fractional
    assert ventilation.schedule == schedule
Exemplo n.º 27
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()
Exemplo n.º 28
0
def test_schedule_day_init():
    """Test the initialization of ScheduleDay and basic properties."""
    simple_office = ScheduleDay('Simple Office Occupancy', [0, 1, 0],
                                [Time(0, 0), Time(9, 0), Time(17, 0)])
    str(simple_office)  # test the string representation

    assert simple_office.name == 'Simple Office Occupancy'
    assert len(simple_office.values) == 3
    assert len(simple_office.times) == 3
    for t in simple_office.times:
        assert isinstance(t, Time)
    assert not simple_office.interpolate
    assert not simple_office.is_constant
Exemplo n.º 29
0
def test_lighting_lockability():
    """Test the lockability of Lighting objects."""
    weekday_office = ScheduleDay(
        'Weekday Office Lighting', [0, 1, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    saturday_office = ScheduleDay(
        'Saturday Office Lighting', [0, 0.25, 0],
        [Time(0, 0), Time(9, 0), Time(17, 0)])
    weekend_rule = ScheduleRule(saturday_office)
    weekend_rule.apply_weekend = True
    schedule = ScheduleRuleset('Office Lighting', weekday_office,
                               [weekend_rule], schedule_types.fractional)
    lighting = Lighting('Open Office Zone Lighting', 10, schedule)

    lighting.watts_per_area = 6
    lighting.lock()
    with pytest.raises(AttributeError):
        lighting.watts_per_area = 8
    with pytest.raises(AttributeError):
        lighting.schedule.default_day_schedule.remove_value_by_time(Time(
            17, 0))
    lighting.unlock()
    lighting.watts_per_area = 8
    with pytest.raises(AttributeError):
        lighting.schedule.default_day_schedule.remove_value_by_time(Time(
            17, 0))
Exemplo n.º 30
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