Пример #1
0
def test_from_dict_vent_opening():
    """Test the Room2D from_dict method with ventilation opening energy properties."""
    pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10,
                                                        3), Point3D(0, 10, 3))
    ashrae_base = SimpleWindowRatio(0.4)
    room = Room2D('SquareShoebox', Face3D(pts), 3)
    room.set_outdoor_window_parameters(ashrae_base)

    ventilation = VentilationControl()
    ventilation.min_indoor_temperature = 22
    ventilation.max_indoor_temperature = 28
    ventilation.min_outdoor_temperature = 12
    ventilation.max_outdoor_temperature = 32
    ventilation.delta_temperature = 0

    opening = VentilationOpening()
    opening.fraction_area_operable = 0.25
    opening.fraction_height_operable = 0.5
    opening.wind_cross_vent = True

    room.properties.energy.window_vent_control = ventilation
    room.properties.energy.window_vent_opening = opening

    rd = room.to_dict()
    new_room = Room2D.from_dict(rd)
    assert new_room.to_dict() == rd
Пример #2
0
def model_energy_window_ventilation(directory):
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.add_default_ideal_air()
    south_face = room[3]
    north_face = room[1]
    south_face.apertures_by_ratio(0.4, 0.01)
    north_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].is_operable = True
    north_face.apertures[0].is_operable = True

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

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

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

    dest_file = os.path.join(directory, 'model_energy_window_ventilation.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
Пример #3
0
def test_set_window_opening():
    """Test the setting of window openings on a Room2D."""
    pts = (Point3D(0, 0, 3), Point3D(10, 0, 3), Point3D(10, 10,
                                                        3), Point3D(0, 10, 3))
    ashrae_base = SimpleWindowRatio(0.4)
    room = Room2D('SquareShoebox', Face3D(pts), 3)
    room.set_outdoor_window_parameters(ashrae_base)

    ventilation = VentilationControl()
    ventilation.min_indoor_temperature = 22
    ventilation.max_indoor_temperature = 28
    ventilation.min_outdoor_temperature = 12
    ventilation.max_outdoor_temperature = 32
    ventilation.delta_temperature = 0

    opening = VentilationOpening()
    opening.fraction_area_operable = 0.25
    opening.fraction_height_operable = 0.5
    opening.wind_cross_vent = True

    room.properties.energy.window_vent_control = ventilation
    room.properties.energy.window_vent_opening = opening

    hb_room, adj = room.to_honeybee()
    assert hb_room.properties.energy.window_vent_control == ventilation
    assert hb_room[1].apertures[0].properties.energy.vent_opening == opening
Пример #4
0
def test_ventilation_control_equality():
    """Test the equality of VentilationControl objects."""
    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(18, schedule=schedule)
    ventilation_dup = ventilation.duplicate()
    ventilation_alt = VentilationControl(20)
    ventilation_alt.schedule = schedule

    assert ventilation is ventilation
    assert ventilation is not ventilation_dup
    assert ventilation == ventilation_dup
    ventilation_dup.delta_temperature = -2
    assert ventilation != ventilation_dup
    assert ventilation != ventilation_alt
Пример #5
0
def test_ventilation_control_lockability():
    """Test the lockability of Ventilation objects."""
    ventilation = VentilationControl(20)

    ventilation.delta_temperature = -2
    ventilation.lock()
    with pytest.raises(AttributeError):
        ventilation.min_indoor_temperature = 22
    ventilation.unlock()
    ventilation.min_indoor_temperature = 22
Пример #6
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)
Пример #7
0
def test_run_idf_window_ventilation():
    """Test the Model.to.idf and run_idf method with a model possessing operable windows."""
    room = Room.from_box('TinyHouseZone', 5, 10, 3)
    room.properties.energy.add_default_ideal_air()
    south_face = room[3]
    north_face = room[1]
    south_face.apertures_by_ratio(0.4, 0.01)
    north_face.apertures_by_ratio(0.4, 0.01)
    south_face.apertures[0].is_operable = True
    north_face.apertures[0].is_operable = True

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

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

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

    # Get the input SimulationParameter
    sim_par = SimulationParameter()
    sim_par.output.add_zone_energy_use()
    ddy_file = './tests/ddy/chicago.ddy'
    sim_par.sizing_parameter.add_from_ddy_996_004(ddy_file)
    sim_par.run_period.end_date = Date(6, 7)
    sim_par.run_period.start_date = Date(6, 1)

    # create the IDF string for simulation paramters and model
    idf_str = '\n\n'.join((sim_par.to_idf(), model.to.idf(model)))

    # write the final string into an IDF
    idf = os.path.join(folders.default_simulation_folder,
                       'test_file_window_vent', 'in.idf')
    write_to_file(idf, idf_str, True)

    # prepare the IDF for simulation
    epw_file = './tests/simulation/chicago.epw'
    prepare_idf_for_simulation(idf, epw_file)

    # run the IDF through EnergyPlus
    sql, zsz, rdd, html, err = run_idf(idf, epw_file)

    assert os.path.isfile(sql)
    assert os.path.isfile(err)
    err_obj = Err(err)
    assert 'EnergyPlus Completed Successfully' in err_obj.file_contents
Пример #8
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
Пример #9
0
def test_ventilation_dict_methods():
    """Test the to/from dict methods."""
    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(22, 28, 12, 32, 0)

    vent_dict = ventilation.to_dict()
    new_ventilation = VentilationControl.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 = VentilationControl.from_dict(vent_dict)
    assert new_ventilation == ventilation
    assert vent_dict == new_ventilation.to_dict()
Пример #10
0
def test_ventilation_opening_to_idf():
    """Test the initialization of Ventilation from_idf."""
    room = Room.from_box('ShoeBoxZone', 5, 10, 3)
    south_face = room[3]
    south_face.apertures_by_ratio(0.4, 0.01)
    aperture = south_face.apertures[0]
    aperture.is_operable = True
    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)
    vent_control = VentilationControl(18, schedule=schedule)
    room.properties.energy.window_vent_control = vent_control

    ventilation = VentilationOpening()
    with pytest.raises(AssertionError):
        ventilation.to_idf()
    aperture.properties.energy.vent_opening = ventilation

    idf_str = ventilation.to_idf()
    assert room.identifier in idf_str
    assert schedule.identifier in idf_str
Пример #11
0
def test_ventilation_control_init():
    """Test the initialization of VentilationControl and basic properties."""
    ventilation = VentilationControl()
    str(ventilation)  # test the string representation

    assert ventilation.min_indoor_temperature == -100
    assert ventilation.max_indoor_temperature == 100
    assert ventilation.min_outdoor_temperature == -100
    assert ventilation.max_outdoor_temperature == 100
    assert ventilation.delta_temperature == -100
    assert ventilation.schedule == always_on

    ventilation.min_indoor_temperature = 22
    ventilation.max_indoor_temperature = 28
    ventilation.min_outdoor_temperature = 12
    ventilation.max_outdoor_temperature = 32
    ventilation.delta_temperature = 0

    assert ventilation.min_indoor_temperature == 22
    assert ventilation.max_indoor_temperature == 28
    assert ventilation.min_outdoor_temperature == 12
    assert ventilation.max_outdoor_temperature == 32
    assert ventilation.delta_temperature == 0
Пример #12
0
def ventilation_control_simple(directory):
    ventilation = VentilationControl(22)

    dest_file = os.path.join(directory, 'ventilation_control_simple.json')
    with open(dest_file, 'w') as fp:
        json.dump(ventilation.to_dict(abridged=True), fp, indent=4)
Пример #13
0
def model_energy_afn_multizone(directory):

    # south Room
    szone_pts = Face3D(
        [Point3D(0, 0),
         Point3D(20, 0),
         Point3D(20, 10),
         Point3D(0, 10)])
    sroom = Room.from_polyface3d('SouthRoom',
                                 Polyface3D.from_offset_face(szone_pts, 3))

    # north Room
    nzone_pts = Face3D(
        [Point3D(0, 10),
         Point3D(20, 10),
         Point3D(20, 20),
         Point3D(0, 20)])
    nroom = Room.from_polyface3d('NorthRoom',
                                 Polyface3D.from_offset_face(nzone_pts, 3))

    # add exterior windows on east/west faces
    sroom[2].apertures_by_ratio(0.3)
    nroom[4].apertures_by_ratio(0.3)
    sroom[2].apertures[0].is_operable = True
    nroom[4].apertures[0].is_operable = True

    # add small interior windows on north/south faces
    sroom[3].apertures_by_ratio(0.15)
    nroom[1].apertures_by_ratio(0.15)
    sroom[3].apertures[0].is_operable = True
    nroom[1].apertures[0].is_operable = True

    # ventilation openings
    vent_openings = VentilationOpening(fraction_area_operable=1,
                                       fraction_height_operable=1,
                                       discharge_coefficient=0.6,
                                       wind_cross_vent=False,
                                       flow_coefficient_closed=0.001,
                                       flow_exponent_closed=0.667,
                                       two_way_threshold=0.0001)

    sroom.properties.energy.assign_ventilation_opening(vent_openings)
    nroom.properties.energy.assign_ventilation_opening(
        vent_openings.duplicate())

    # make ventilation control
    heat_setpt = ScheduleRuleset.from_constant_value(
        'House Heating', 20, schedule_types.temperature)
    cool_setpt = ScheduleRuleset.from_constant_value(
        'House Cooling', 28, schedule_types.temperature)
    setpoint = Setpoint('House Setpoint', heat_setpt, cool_setpt)
    sroom.properties.energy.setpoint = setpoint
    nroom.properties.energy.setpoint = setpoint.duplicate()

    vent_control = VentilationControl(22, 27, 12, 30)
    sroom.properties.energy.window_vent_control = vent_control
    nroom.properties.energy.window_vent_control = vent_control.duplicate()

    # rooms
    rooms = [sroom, nroom]
    for room in rooms:
        # Add program and hvac
        room.properties.energy.program_type = prog_type_lib.office_program

    # make model
    model = Model('Two_Zone_Simple', rooms)
    vsc = VentilationSimulationControl(
        vent_control_type='MultiZoneWithoutDistribution',
        building_type='LowRise',
        long_axis_angle=0,
        aspect_ratio=1)
    model.properties.energy.ventilation_simulation_control = vsc

    # make interior faces
    Room.solve_adjacency(rooms, 0.01)

    # make afn
    afn.generate(model.rooms)

    dest_file = os.path.join(directory, 'model_energy_afn.json')
    with open(dest_file, 'w') as fp:
        json.dump(model.to_dict(included_prop=['energy']), fp, indent=4)
        vent_cntrl: HBZones with their airflow modified.
"""

ghenv.Component.Name = 'HB Ventilation Control'
ghenv.Component.NickName = 'VentControl'
ghenv.Component.Message = '1.5.0'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '3 :: Loads'
ghenv.Component.AdditionalHelpFromDocStrings = '4'

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

# set default values
min_in_temp_ = -100 if min_in_temp_ is None else min_in_temp_
max_in_temp_ = 100 if max_in_temp_ is None else max_in_temp_
min_out_temp_ = -100 if min_out_temp_ is None else min_out_temp_
max_out_temp_ = 100 if max_out_temp_ is None else max_out_temp_
delta_temp_ = -100 if delta_temp_ is None else delta_temp_

# get the schedule if it's just an identifier
if isinstance(_schedule_, str):
    _schedule_ = schedule_by_identifier(_schedule_)

# create the VentilationControl object
vent_cntrl = VentilationControl(min_in_temp_, max_in_temp_, min_out_temp_,
                                max_out_temp_, delta_temp_, _schedule_)