Exemplo n.º 1
0
def test_sqlite_component_sizing():
    """Test the properties and methods related to component sizes."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)

    comp_sizes = sql_obj.component_sizes
    comp_size_type = sql_obj.component_sizes_by_type('ZoneHVAC:IdealLoadsAirSystem')
    comp_types = sql_obj.component_types

    assert len(comp_sizes) == 7
    assert len(comp_size_type) == 7
    assert comp_types == ['ZoneHVAC:IdealLoadsAirSystem']

    for size_obj in comp_sizes:
        assert isinstance(size_obj, ComponentSize)
        assert size_obj.component_type == 'ZoneHVAC:IdealLoadsAirSystem'
        assert isinstance(size_obj.component_name, str)
        assert all(isinstance(desc, str) for desc in size_obj.descriptions)
        assert all(isinstance(prop, str) for prop in size_obj.properties)
        assert all(isinstance(val, float) for val in size_obj.values)
        assert all(isinstance(unit, str) for unit in size_obj.units)
        assert isinstance(size_obj.properties_dict, dict)
        assert len(size_obj.properties_dict) == 4
        size_dict = size_obj.to_dict()
        new_size = ComponentSize.from_dict(size_dict)
        assert new_size.to_dict() == size_dict
Exemplo n.º 2
0
def test_colorrooms_monthly():
    """Test the initialization of ColorRoom with monthly data."""
    sql_path = './tests/result/eplusout_monthly.sql'
    sql_obj = SQLiteResult(sql_path)
    lighting_data = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    rooms = []
    for i in range(7):
        rooms.append(
            Room.from_box('Residence_{}'.format(i + 1),
                          3,
                          6,
                          3.2,
                          origin=Point3D(3 * i, 0, 0)))
    color_obj = ColorRoom(lighting_data, rooms)

    assert len(color_obj.graphic_container.value_colors) == 7
    assert color_obj.unit == 'kWh/m2'
    assert isinstance(color_obj.data_type, EnergyIntensity)
    assert color_obj.data_type_text == 'Zone Lights Electric Energy'
    assert color_obj.time_interval_text(0) == 'Jan'
    assert color_obj.title_text == 'Total Zone Lights Electric Energy Intensity ' \
        '(kWh/m2)\n1/1 to 12/31 between 0 and 23 '

    color_obj.simulation_step = 0
    assert color_obj.title_text == 'Zone Lights Electric Energy Intensity (kWh/m2)\nJan'
Exemplo n.º 3
0
def test_colorrooms_temperature():
    """Test the initialization of ColorRoom with temperature data."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)
    lighting_data = sql_obj.data_collections_by_output_name(
        'Zone Mean Radiant Temperature')
    rooms = []
    for i in range(7):
        rooms.append(
            Room.from_box('Residence_{}'.format(i + 1),
                          3,
                          6,
                          3.2,
                          origin=Point3D(3 * i, 0, 0)))
    color_obj = ColorRoom(lighting_data, rooms)

    assert len(color_obj.graphic_container.value_colors) == 7
    assert color_obj.unit == 'C'
    assert isinstance(color_obj.data_type, Temperature)
    assert color_obj.data_type_text == 'Zone Mean Radiant Temperature'
    assert color_obj.time_interval_text(0) == '06 Jan 00:00'
    assert color_obj.title_text == 'Average Zone Mean Radiant Temperature ' \
        '(C)\n1/6 to 1/12 between 0 and 23 '

    color_obj.simulation_step = 0
    assert color_obj.title_text == 'Zone Mean Radiant Temperature (C)\n06 Jan 00:00'
Exemplo n.º 4
0
def test_colorrooms_not_normalized():
    """Test the initialization of ColorRoom without normalizing data by floor area."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)
    lighting_data = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    rooms = []
    for i in range(7):
        rooms.append(
            Room.from_box('Residence_{}'.format(i + 1),
                          3,
                          6,
                          3.2,
                          origin=Point3D(3 * i, 0, 0)))
    color_obj = ColorRoom(lighting_data, rooms, normalize_by_floor=False)

    assert len(color_obj.graphic_container.value_colors) == 7
    assert color_obj.unit == 'kWh'
    assert isinstance(color_obj.data_type, Energy)
    assert color_obj.data_type_text == 'Zone Lights Electric Energy'
    assert color_obj.time_interval_text(0) == '06 Jan 00:00'
    assert color_obj.title_text == 'Total Zone Lights Electric Energy ' \
        '(kWh)\n1/6 to 1/12 between 0 and 23 '

    color_obj.simulation_step = 0
    assert color_obj.title_text == 'Zone Lights Electric Energy (kWh)\n06 Jan 00:00'
Exemplo n.º 5
0
def test_sqlite_data_collections_by_output_name_timestep():
    """Test the data_collections_by_output_name method with timestep values."""
    sql_path = './tests/result/eplusout_timestep.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == 7 * 24 * 6
Exemplo n.º 6
0
def test_sqlite_data_collections_by_output_name():
    """Test the data_collections_by_output_name method."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    assert len(data_colls) == 7
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == len(coll.header.analysis_period.hoys)
        assert isinstance(coll.header.data_type, Energy)
        assert coll.header.unit == 'kWh'

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Mean Radiant Temperature')
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == len(coll.header.analysis_period.hoys)
        assert isinstance(coll.header.data_type, Temperature)
        assert coll.header.unit == 'C'

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Electric Equipment Electric Energy')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Mean Air Temperature')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Air Relative Humidity')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Ideal Loads Supply Air Total Heating Energy')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Ideal Loads Supply Air Total Cooling Energy')
Exemplo n.º 7
0
def test_sqlite_data_collections_by_output_name_design_day():
    """Test the data_collections_by_output_name method with several design day results."""
    sql_path = './tests/result/eplusout_design_days.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    assert len(data_colls) == 49
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == 24
Exemplo n.º 8
0
def test_sqlite_data_collections_by_output_name_monthly():
    """Test the data_collections_by_output_name method with monthly values."""
    sql_path = './tests/result/eplusout_monthly.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    for coll in data_colls:
        assert isinstance(coll, MonthlyCollection)
        assert coll.header.analysis_period.is_annual
        assert len(coll) == 12
Exemplo n.º 9
0
def test_sqlite_data_collections_by_output_names():
    """Test the data_collections_by_output_name method with multiple names."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        ('Zone Lights Electric Energy', 'Zone Mean Radiant Temperature'))
    assert len(data_colls) == 14
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == len(coll.header.analysis_period.hoys)
        assert isinstance(coll.header.data_type, (Energy, Temperature))
Exemplo n.º 10
0
def test_sqlite_data_collections_by_output_name_single():
    """Test the data_collections_by_output_name method with a single data."""
    sql_path = './tests/result/eplusout_openstudio_error.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    assert len(data_colls) == 1
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == len(coll.header.analysis_period.hoys)
        assert isinstance(coll.header.data_type, Energy)
        assert coll.header.unit == 'kWh'
Exemplo n.º 11
0
def test_colorrooms_init():
    """Test the initialization of ColorRoom and basic properties."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)
    lighting_data = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    rooms = []
    for i in range(7):
        rooms.append(
            Room.from_box('Residence_{}'.format(i + 1),
                          3,
                          6,
                          3.2,
                          origin=Point3D(3 * i, 0, 0)))
    color_obj = ColorRoom(lighting_data, rooms)

    str(color_obj)
    assert len(color_obj.data_collections) == 7
    for coll in color_obj.data_collections:
        assert isinstance(coll, HourlyContinuousCollection)
        assert coll.header.unit == 'kWh'
    assert isinstance(color_obj.legend_parameters, LegendParameters)
    assert color_obj.simulation_step is None
    assert color_obj.normalize_by_floor
    assert color_obj.geo_unit == 'm'
    assert len(color_obj.matched_rooms) == 7
    assert len(color_obj.matched_values) == 7
    for val in color_obj.matched_values:
        assert isinstance(val, (float, int))
    assert len(color_obj.matched_floor_faces) == 7
    for face_array in color_obj.matched_floor_faces:
        assert len(face_array) == 1
        assert isinstance(face_array[0], Face3D)
    assert len(color_obj.matched_floor_areas) == 7
    for val in color_obj.matched_floor_areas:
        assert isinstance(val, (float, int))
    assert isinstance(color_obj.graphic_container, GraphicContainer)
    assert len(color_obj.graphic_container.value_colors) == 7
    assert color_obj.unit == 'kWh/m2'
    assert isinstance(color_obj.data_type, EnergyIntensity)
    assert color_obj.data_type_text == 'Zone Lights Electric Energy'
    assert color_obj.time_interval_text(0) == '06 Jan 00:00'
    assert color_obj.title_text == 'Total Zone Lights Electric Energy Intensity ' \
        '(kWh/m2)\n1/6 to 1/12 between 0 and 23 '

    color_obj.simulation_step = 0
    assert color_obj.title_text == 'Zone Lights Electric Energy Intensity ' \
        '(kWh/m2)\n06 Jan 00:00'

    with pytest.raises(AssertionError):
        color_obj.simulation_step = 8760
Exemplo n.º 12
0
def test_sqlite_run_period():
    """Test the run_period property of SQLiteResult."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)

    assert len(sql_obj.run_periods) == 1
    assert isinstance(sql_obj.run_periods[0], AnalysisPeriod)
    assert sql_obj.run_periods[0].st_month == 1
    assert sql_obj.run_periods[0].st_day == 6
    assert sql_obj.run_periods[0].end_month == 1
    assert sql_obj.run_periods[0].end_day == 12

    sql_path = './tests/result/eplusout_design_days.sql'
    sql_obj = SQLiteResult(sql_path)
    assert len(sql_obj.run_periods) == 7
Exemplo n.º 13
0
def test_sqlite_zone_sizing():
    """Test the properties and methods related to zone sizes."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)

    cool_sizes = sql_obj.zone_cooling_sizes
    heat_sizes = sql_obj.zone_heating_sizes

    assert len(cool_sizes) == 7
    assert len(heat_sizes) == 7

    for size_obj in cool_sizes:
        assert isinstance(size_obj, ZoneSize)
        assert isinstance(size_obj.zone_name, str)
        assert size_obj.load_type == 'Cooling'
        assert isinstance(size_obj.calculated_design_load, float)
        assert isinstance(size_obj.final_design_load, float)
        assert isinstance(size_obj.calculated_design_flow, float)
        assert isinstance(size_obj.final_design_flow, float)
        assert size_obj.design_day_name == 'BOSTON LOGAN INTL ARPT ANN CLG .4% CONDNS DB=>MWB'
        assert isinstance(size_obj.peak_date_time, DateTime)
        assert isinstance(size_obj.peak_temperature, float)
        assert isinstance(size_obj.peak_humidity_ratio, float)
        assert isinstance(size_obj.peak_outdoor_air_flow, float)
        size_dict = size_obj.to_dict()
        new_size = ZoneSize.from_dict(size_dict)
        assert new_size.to_dict() == size_dict

    for size_obj in heat_sizes:
        assert size_obj.load_type == 'Heating'
        assert size_obj.design_day_name == 'BOSTON LOGAN INTL ARPT ANN HTG 99.6% CONDNS DB'
Exemplo n.º 14
0
def test_colorfaces_triangulated():
    """Test the initialization of ColorFace with a triangulated aperture."""
    model_json = './tests/result/triangulated/TriangleModel.json'
    with open(model_json, 'r') as fp:
        model_data = json.load(fp)
    model = Model.from_dict(model_data)

    sql_path = './tests/result/triangulated/eplusout.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Surface Inside Face Temperature')
    color_obj = ColorFace(data_colls, model.rooms[0].faces)
    assert len(color_obj.matched_values) == 8

    data_colls = sql_obj.data_collections_by_output_name(
        'Surface Window Heat Loss Energy')
    color_obj = ColorFace(data_colls, model.rooms[0].faces)
    assert len(color_obj.matched_values) == 1

    data_colls = sql_obj.data_collections_by_output_name(
        'Surface Average Face Conduction Heat Transfer Energy')
    color_obj = ColorFace(data_colls, model.rooms[0].faces)
    assert len(color_obj.matched_values) == 7
Exemplo n.º 15
0
def test_sqlite_init():
    """Test the initialization of SQLiteResult and basic properties."""
    sql_path = './tests/result/eplusout_hourly.sql'
    sql_obj = SQLiteResult(sql_path)
    str(sql_obj)  # test the string representation

    assert isinstance(sql_obj.file_path, str)
    assert isinstance(sql_obj.location, Location)
    assert sql_obj.location.latitude == 42.37

    all_output = sql_obj.available_outputs
    assert len(all_output) == 8
    assert 'Zone Operative Temperature' in all_output
    assert 'Zone Lights Electric Energy' in all_output
    assert 'Zone Electric Equipment Electric Energy' in all_output
    assert 'Zone Air Relative Humidity' in all_output
    assert 'Zone Ideal Loads Supply Air Total Cooling Energy' in all_output
    assert 'Zone Mean Radiant Temperature' in all_output
    assert 'Zone Ideal Loads Supply Air Total Heating Energy' in all_output
Exemplo n.º 16
0
def test_sqlite_data_collections_by_output_name_openstudio():
    """Test the data_collections_by_output_name method with openstudio values."""
    sql_path = './tests/result/eplusout_openstudio.sql'
    sql_obj = SQLiteResult(sql_path)

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Lights Electric Energy')
    for coll in data_colls:
        assert isinstance(coll, HourlyContinuousCollection)
        assert len(coll) == len(coll.header.analysis_period.hoys)
        assert isinstance(coll.header.data_type, Energy)
        assert coll.header.unit == 'kWh'

    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Electric Equipment Electric Energy')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Ideal Loads Supply Air Total Heating Energy')
    data_colls = sql_obj.data_collections_by_output_name(
        'Zone Ideal Loads Supply Air Total Cooling Energy')

def subtract_loss_from_gain(gain_load, loss_load):
    """Create a single DataCollection from gains and losses."""
    total_loads = []
    for gain, loss in zip(gain_load, loss_load):
        total_load = gain - loss
        total_load.header.metadata['type'] = \
            total_load.header.metadata['type'].replace('Gain ', '')
        total_loads.append(total_load)
    return total_loads


if all_required_inputs(ghenv.Component):
    # create the SQL result parsing object
    sql_obj = SQLiteResult(_sql)

    # get all of the results relevant for energy use
    cooling = sql_obj.data_collections_by_output_name(
        ('Zone Ideal Loads Supply Air Total Cooling Energy',
         'Zone Ideal Loads Zone Sensible Cooling Energy',
         'Zone Ideal Loads Zone Latent Cooling Energy',
         'Cooling Coil Electric Energy', 'Chiller Electric Energy',
         'Zone VRF Air Terminal Cooling Electric Energy',
         'VRF Heat Pump Cooling Electric Energy',
         'Chiller Heater System Cooling Electric Energy'))
    heating = sql_obj.data_collections_by_output_name(
        ('Zone Ideal Loads Supply Air Total Heating Energy',
         'Zone Ideal Loads Zone Sensible Heating Energy',
         'Zone Ideal Loads Zone Latent Heating Energy', 'Boiler Gas Energy',
         'Heating Coil Total Heating Energy', 'Heating Coil Gas Energy',
Exemplo n.º 18
0

def subtract_loss_from_gain(gain_load, loss_load):
    """Create a single DataCollection from gains and losses."""
    total_loads = []
    for gain, loss in zip(gain_load, loss_load):
        total_load = gain - loss
        total_load.header.metadata['type'] = \
            total_load.header.metadata['type'].replace('Gain ', '')
        total_loads.append(total_load)
    return total_loads


if all_required_inputs(ghenv.Component):
    # create the SQL result parsing object
    sql_obj = SQLiteResult(_sql)

    # get all of the results
    face_indoor_temp = sql_obj.data_collections_by_output_name(
        'Surface Inside Face Temperature')
    face_outdoor_temp = sql_obj.data_collections_by_output_name(
        'Surface Outside Face Temperature')
    opaque_energy_flow = sql_obj.data_collections_by_output_name(
        'Surface Average Face Conduction Heat Transfer Energy')

    window_loss = sql_obj.data_collections_by_output_name(
        'Surface Window Heat Loss Energy')
    window_gain = sql_obj.data_collections_by_output_name(
        'Surface Window Heat Gain Energy')
    window_energy_flow = []
    if len(window_gain) == len(window_loss):
Exemplo n.º 19
0
            'Surface Window System Solar Transmittance'. These data corresponding
            to these outputs will be returned from this component.
    
    Returns:
        results: DataCollections for the output_names.
"""

ghenv.Component.Name = 'HB Read Custom Result'
ghenv.Component.NickName = 'RoomCustomResult'
ghenv.Component.Message = '0.1.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '6 :: Result'
ghenv.Component.AdditionalHelpFromDocStrings = '1'

try:
    from honeybee_energy.result.sql import SQLiteResult
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))

if all_required_inputs(ghenv.Component):
    # create the SQL result parsing object
    sql_obj = SQLiteResult(_sql)

    # get all of the results
    results = sql_obj.data_collections_by_output_name(_output_names)
Exemplo n.º 20
0
ghenv.Component.Name = 'HB Read Room Comfort Result'
ghenv.Component.NickName = 'RoomComfortResult'
ghenv.Component.Message = '0.1.1'
ghenv.Component.Category = 'HB-Energy'
ghenv.Component.SubCategory = '6 :: Result'
ghenv.Component.AdditionalHelpFromDocStrings = '1'

try:
    from honeybee_energy.result.sql import SQLiteResult
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))

if all_required_inputs(ghenv.Component):
    # create the SQL result parsing object
    sql_obj = SQLiteResult(_sql)

    # get all of the results
    oper_temp = sql_obj.data_collections_by_output_name(
        'Zone Operative Temperature')
    air_temp = sql_obj.data_collections_by_output_name(
        'Zone Mean Air Temperature')
    rad_temp = sql_obj.data_collections_by_output_name(
        'Zone Mean Radiant Temperature')
    rel_humidity = sql_obj.data_collections_by_output_name(
        'Zone Air Relative Humidity')