Ejemplo n.º 1
0
def test_energy_ventilation_simulation_properties():
    """Test the existence of the ventilation simulation control properties."""
    room = Room.from_box('Tiny_House_Zone', 5, 10, 3)
    room.properties.energy.program_type = office_program
    room.properties.energy.add_default_ideal_air()

    # ModelEnergyProperties will set ventilation cooling to single zone
    model = Model('Tiny_House', [room])
    assert hasattr(model.properties.energy, 'ventilation_simulation_control')

    vent = model.properties.energy.ventilation_simulation_control
    assert isinstance(vent, VentilationSimulationControl)
    assert vent.vent_control_type == 'SingleZone'
    assert vent.reference_temperature == pytest.approx(20, abs=1e-10)
    assert vent.reference_pressure == pytest.approx(101325, abs=1e-10)
    assert vent.reference_humidity_ratio == pytest.approx(0, abs=1e-10)
    assert vent.building_type == 'LowRise'
    assert vent.long_axis_angle == pytest.approx(0, abs=1e-10)
    assert vent.aspect_ratio == pytest.approx(1, abs=1e-10)

    # Test to_dict
    data = model.properties.energy.to_dict()
    assert 'ventilation_simulation_control' in data['energy']
    vent_dict = data['energy']['ventilation_simulation_control']
    vent_dict['reference_temperature'] == pytest.approx(20, abs=1e-10)
    vent_dict['building_type'] == 'LowRise'
    new_vent = VentilationSimulationControl.from_dict(vent_dict)
    assert new_vent == VentilationSimulationControl()
    assert vent_dict == new_vent.to_dict()

    # Add sim control obj
    model.properties.energy.ventilation_simulation_control = \
        VentilationSimulationControl('MultiZoneWithoutDistribution', 21, 101320, 0.5)
    vent = model.properties.energy.ventilation_simulation_control
    assert vent.vent_control_type == 'MultiZoneWithoutDistribution'
Ejemplo n.º 2
0
def ventilation_simulation_control(directory):
    vent_sim = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 21, 101325, 0.5, 'LowRise', 90, 0.5)

    dest_file = os.path.join(directory, 'ventilation_simulation_control.json')
    with open(dest_file, 'w') as fp:
        json.dump(vent_sim.to_dict(), fp, indent=4)
Ejemplo n.º 3
0
def test_simulation_control_equality():
    """Test the equality of VentilationSimulationControl objects."""
    ventilation = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 21, 101325, 0.5, 'LowRise', 90, 0.5)
    ventilation_dup = ventilation.duplicate()
    ventilation_alt = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 22, 101321, 0.6, 'LowRise', 91, 0.7)

    assert ventilation is ventilation
    assert ventilation is not ventilation_dup
    assert ventilation == ventilation_dup
    ventilation_dup.reference_temperature = 30.0
    assert ventilation != ventilation_dup
    assert ventilation != ventilation_alt
Ejemplo n.º 4
0
def test_simulation_control_lockability():
    """Test the lockability of VentilationSimultionControl objects."""
    ventilation = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 21, 101325, 0.5, 'LowRise', 90, 0.5)

    ventilation.reference_pressure = 101340
    ventilation.lock()
    with pytest.raises(AttributeError):
        ventilation.reference_pressure = 30999
    ventilation.unlock()
    ventilation.reference_pressure = 31000
Ejemplo n.º 5
0
def test_ventilation_dict_methods():
    """Test the to/from dict methods."""
    ventilation = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 21, 101325, 0.5, 'LowRise', 90, 0.5)

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

    # Test values
    vent_dict['reference_temperature'] == pytest.approx(20, abs=1e-10)
    vent_dict['building_type'] == 'LowRise'

    new_ventilation.reference_pressure == \
        pytest.approx(101325, 1e-10)
    new_ventilation.building_type == 'LowRise'
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
def test_simulation_control_init():
    """Test the initialization of VentilationSimulationControl."""
    # Test SingleZone w/ defaults and str
    vent = VentilationSimulationControl('SingleZone')
    vent.__repr__()

    # Test MultiZone
    vent = VentilationSimulationControl(
        'MultiZoneWithoutDistribution', 21, 101325, 0.5, 'LowRise', 90, 0.5)

    assert vent.vent_control_type == 'MultiZoneWithoutDistribution'
    assert vent.reference_temperature == pytest.approx(21, abs=1e-10)
    assert vent.reference_pressure == pytest.approx(101325, abs=1e-10)
    assert vent.reference_humidity_ratio == pytest.approx(0.5, abs=1e-10)
    assert vent.building_type == 'LowRise'
    assert vent.long_axis_angle == pytest.approx(90, abs=1e-10)
    assert vent.aspect_ratio == pytest.approx(0.5, abs=1e-10)

    # Test setting incorrect values
    with pytest.raises(AssertionError):
        vent.vent_control_type = 'SingleZne'
    with pytest.raises(TypeError):
        vent.reference_temperature = 'abc'
    with pytest.raises(AssertionError):
        vent.reference_pressure = 120000.001
    with pytest.raises(AssertionError):
        vent.reference_humidity_ratio = -1
    with pytest.raises(AssertionError):
        vent.building_type = 'MidRise'
    with pytest.raises(AssertionError):
        vent.long_axis_angle = 360
    with pytest.raises(AssertionError):
        vent.aspect_ratio = 0