def test_shade_init(): """Test the initalization of shade material objects and basic properties.""" shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) str(shade_mat) # test the string representation of the material shade_dup = shade_mat.duplicate() assert shade_mat.identifier == shade_dup.identifier == 'Low-e Diffusing Shade' assert shade_mat.thickness == shade_dup.thickness == 0.025 assert shade_mat.solar_transmittance == shade_dup.solar_transmittance == 0.15 assert shade_mat.solar_reflectance == shade_dup.solar_reflectance == 0.5 assert shade_mat.visible_transmittance == shade_dup.visible_transmittance == 0.25 assert shade_mat.visible_reflectance == shade_dup.visible_reflectance == 0.5 assert shade_mat.infrared_transmittance == shade_dup.infrared_transmittance == 0 assert shade_mat.emissivity == shade_dup.emissivity == 0.4 assert shade_mat.conductivity == shade_dup.conductivity == 0.2 assert shade_mat.distance_to_glass == shade_dup.distance_to_glass == 0.1 assert shade_mat.top_opening_multiplier == shade_dup.top_opening_multiplier == 0.75 assert shade_mat.bottom_opening_multiplier == shade_dup.bottom_opening_multiplier == 0.75 assert shade_mat.left_opening_multiplier == shade_dup.left_opening_multiplier == 0.75 assert shade_mat.right_opening_multiplier == shade_dup.right_opening_multiplier == 0.75 assert shade_mat.airflow_permeability == shade_dup.airflow_permeability == 0.25 assert shade_mat.resistivity == shade_dup.resistivity == 5 assert shade_mat.u_value == shade_dup.u_value == 8 assert shade_mat.r_value == shade_dup.r_value == 0.125
def test_shade_dict_methods(): """Test the to/from dict methods.""" shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) material_dict = shade_mat.to_dict() new_material = EnergyWindowMaterialShade.from_dict(material_dict) assert material_dict == new_material.to_dict()
def test_window_construction_init_shade(): """Test the initalization of WindowConstruction objects with shades.""" lowe_glass = EnergyWindowMaterialGlazing('Low-e Glass', 0.00318, 0.4517, 0.359, 0.714, 0.207, 0, 0.84, 0.046578, 1.0) clear_glass = EnergyWindowMaterialGlazing('Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) double_low_e_shade = WindowConstruction( 'Double Low-E with Shade', [lowe_glass, gap, clear_glass, shade_mat]) double_low_e_between_shade = WindowConstruction( 'Double Low-E Between Shade', [lowe_glass, shade_mat, clear_glass]) double_low_e_ext_shade = WindowConstruction( 'Double Low-E Outside Shade', [shade_mat, lowe_glass, gap, clear_glass]) assert double_low_e_shade.name == 'Double Low-E with Shade' assert double_low_e_shade.u_factor == pytest.approx(0.9091, rel=1e-2) assert double_low_e_between_shade.name == 'Double Low-E Between Shade' assert double_low_e_between_shade.u_factor == pytest.approx(1.13374, rel=1e-2) assert double_low_e_ext_shade.name == 'Double Low-E Outside Shade' assert double_low_e_ext_shade.u_factor == pytest.approx(0.97678, rel=1e-2)
def test_window_shade_equivalency(): """Test the equality of a WindowConstructionShade construction to another.""" clear_glass = EnergyWindowMaterialGlazing( 'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) double_clear = WindowConstruction( 'Double Clear Window', [clear_glass, gap, clear_glass]) shade_mat = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) sched = ScheduleRuleset.from_daily_values( 'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) double_low_e_ec = WindowConstructionShade( 'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) double_low_e_ec_2 = double_low_e_ec.duplicate() double_low_e_ec_3 = WindowConstructionShade( 'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior', 'AlwaysOn', None, sched) collection = [double_low_e_ec, double_low_e_ec, double_low_e_ec_2, double_low_e_ec_3] assert len(set(collection)) == 2 assert double_low_e_ec == double_low_e_ec_2 assert double_low_e_ec != double_low_e_ec_3 assert double_low_e_ec_2 != double_low_e_ec_3 double_low_e_ec_2.identifier = 'Cool Window' assert double_low_e_ec != double_low_e_ec_2
def test_window_shade_lockability(): """Test the lockability of the WindowConstructionShade construction.""" clear_glass = EnergyWindowMaterialGlazing( 'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) double_clear = WindowConstruction( 'Double Clear Window', [clear_glass, gap, clear_glass]) shade_mat = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) sched = ScheduleRuleset.from_daily_values( 'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) double_low_e_ec = WindowConstructionShade( 'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) with pytest.raises(AttributeError): double_low_e_ec.window_construction.materials = \ [clear_glass, gap, clear_glass, gap, clear_glass] with pytest.raises(AttributeError): double_low_e_ec.window_construction.schedule.identifier = 'ScheduleName' with pytest.raises(AttributeError): double_low_e_ec.shade_location = 'Interior' double_low_e_ec.control_type = 'AlwaysOn' double_low_e_ec.lock() with pytest.raises(AttributeError): double_low_e_ec.control_type = 'OnIfHighSolarOnWindow' double_low_e_ec.unlock() double_low_e_ec.control_type = 'OnIfHighSolarOnWindow'
def test_shade_from_idf(): """Test the initalization of shade material objects from EnergyPlus strings.""" ep_str_1 = "WindowMaterial:Shade,\n" \ "Default Shade, !- Name\n" \ "0.05, !- Solar Transmittance\n" \ "0.3, !- Front Side Solar Reflectance\n" \ "0.05, !- Visible Transmittance\n" \ "0.3, !- Front Side Visible Reflectance\n" \ "0.86, !- Infrared Hemispherical Emissivity\n" \ "0.04, !- Infrared Transmittance \n" \ "0.003, !- Thickness {m}\n" \ "0.1, !- Conductivity {W/m-K}\n" \ "0.1, !- Distance to Glass {m}\n" \ "1, !- Top Opening Multiplier\n" \ "1, !- Bottom Opening Multiplier\n" \ "1, !- Left Opening Multiplier\n" \ "1, !- Right Opening Multiplier\n" \ "0.04; !- Airflow Permeability" shade_mat = EnergyWindowMaterialShade.from_idf(ep_str_1) assert shade_mat.thickness == 0.003 assert shade_mat.solar_transmittance == 0.05 assert shade_mat.solar_reflectance == 0.3 assert shade_mat.visible_transmittance == 0.05 assert shade_mat.visible_reflectance == 0.3 assert shade_mat.infrared_transmittance == 0.04 assert shade_mat.emissivity == 0.86 assert shade_mat.conductivity == 0.1 assert shade_mat.distance_to_glass == 0.1 assert shade_mat.top_opening_multiplier == 1 assert shade_mat.bottom_opening_multiplier == 1 assert shade_mat.left_opening_multiplier == 1 assert shade_mat.right_opening_multiplier == 1 assert shade_mat.airflow_permeability == 0.04
def construction_window_shade(directory): """Test the initialization of WindowConstructionShade objects with shades.""" shade_mat = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) window_constr = WindowConstruction('Double Low-E', [lowe_glass, argon_gap, clear_glass]) window_with_shade = WindowConstructionShade( 'Double Low-E Outside Shade', window_constr, shade_mat, 'Interior') dest_file = os.path.join(directory, 'construction_window_shade.json') with open(dest_file, 'w') as fp: json.dump(window_with_shade.to_dict(abridged=True), fp, indent=4)
def test_run_idf_window_shade(): """Test the Model.to.idf and run_idf method with a model that has a window shade.""" # Get input Model room = Room.from_box('TinyHouseZone', 5, 10, 3) room.properties.energy.program_type = office_program room.properties.energy.add_default_ideal_air() double_clear = WindowConstruction('Double Pane Clear', [clear_glass, air_gap, clear_glass]) shade_mat = EnergyWindowMaterialShade('Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) sched = ScheduleRuleset.from_daily_values('NighSched', [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 ]) double_ec = WindowConstructionShade('Double Low-E Inside EC', double_clear, shade_mat, 'Interior', 'OnIfHighSolarOnWindow', 200, sched) south_face = room[3] south_face.apertures_by_ratio(0.4, 0.01) south_face.apertures[0].properties.energy.construction = double_ec north_face = room[1] north_face.apertures_by_ratio(0.4, 0.01) 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(1, 7) # 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_shd', '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
def test_shade_defaults(): """Test the EnergyWindowMaterialShade default properties.""" shade_mat = EnergyWindowMaterialShade('Diffusing Shade') assert shade_mat.thickness == 0.005 assert shade_mat.solar_transmittance == 0.4 assert shade_mat.solar_reflectance == 0.5 assert shade_mat.visible_transmittance == 0.4 assert shade_mat.visible_reflectance == 0.4 assert shade_mat.infrared_transmittance == 0 assert shade_mat.emissivity == 0.9 assert shade_mat.conductivity == 0.05 assert shade_mat.distance_to_glass == 0.05 assert shade_mat.top_opening_multiplier == 0.5 assert shade_mat.bottom_opening_multiplier == 0.5 assert shade_mat.left_opening_multiplier == 0.5 assert shade_mat.right_opening_multiplier == 0.5 assert shade_mat.airflow_permeability == 0 assert shade_mat.resistivity == pytest.approx(1 / 0.05, rel=1e-2) assert shade_mat.u_value == pytest.approx(0.05 / 0.005, rel=1e-2) assert shade_mat.r_value == pytest.approx(0.005 / 0.05, rel=1e-2)
def test_window_shade_dict_methods(): """Test the to/from dict methods.""" clear_glass = EnergyWindowMaterialGlazing( 'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) double_clear = WindowConstruction( 'Double Clear Window', [clear_glass, gap, clear_glass]) shade_mat = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) sched = ScheduleRuleset.from_daily_values( 'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) double_low_e_ec = WindowConstructionShade( 'Double Low-E Inside EC', double_clear, shade_mat, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) constr_dict = double_low_e_ec.to_dict() new_constr = WindowConstructionShade.from_dict(constr_dict) assert double_low_e_ec == new_constr assert constr_dict == new_constr.to_dict()
from honeybee_energy.material.shade import EnergyWindowMaterialShade except ImportError as e: raise ImportError('\nFailed to import honeybee_energy:\n\t{}'.format(e)) try: # import ladybug_rhino dependencies 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): # set the default material properties _transmittance_ = 0.4 if _transmittance_ is None else _transmittance_ _reflectance_ = 0.5 if _reflectance_ is None else _reflectance_ _t_infrared_ = 0 if _t_infrared_ is None else _t_infrared_ _emissivity_ = 0.9 if _emissivity_ is None else _emissivity_ _conductivity_ = 0.9 if _conductivity_ is None else _conductivity_ _dist_to_glass_ = 0.05 if _dist_to_glass_ is None else _dist_to_glass_ _open_mult_ = 0.5 if _open_mult_ is None else _open_mult_ _permeability_ = 0.0 if _permeability_ is None else _permeability_ name = clean_and_id_ep_string('ShadeMaterial') if _name_ is None else \ clean_ep_string(_name_) # create the material mat = EnergyWindowMaterialShade(name, _thickness, _transmittance_, _reflectance_, _transmittance_, _reflectance_, _t_infrared_, _emissivity_, _conductivity_, _dist_to_glass_, _open_mult_, _permeability_) if _name_ is not None: mat.display_name = _name_
def test_window_construction_shade_init(): """Test the initialization of WindowConstructionShade objects with shades.""" lowe_glass = EnergyWindowMaterialGlazing( 'Low-e Glass', 0.00318, 0.4517, 0.359, 0.714, 0.207, 0, 0.84, 0.046578, 1.0) clear_glass = EnergyWindowMaterialGlazing( 'Clear Glass', 0.005715, 0.770675, 0.07, 0.8836, 0.0804, 0, 0.84, 0.84, 1.0) gap = EnergyWindowMaterialGas('air gap', thickness=0.0127) shade_mat = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.005, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) shade_thick = EnergyWindowMaterialShade( 'Low-e Diffusing Shade', 0.025, 0.15, 0.5, 0.25, 0.5, 0, 0.4, 0.2, 0.1, 0.75, 0.25) window_constr = WindowConstruction('Double Low-E', [lowe_glass, gap, clear_glass]) window_clear = WindowConstruction('Double Low-E', [clear_glass, gap, clear_glass]) sched = ScheduleRuleset.from_daily_values( 'NighSched', [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]) with pytest.raises(AssertionError): double_low_e_between_shade = WindowConstructionShade( 'Double Low-E Between Shade', window_constr, shade_thick, 'Between') double_low_e_shade = WindowConstructionShade( 'Double Low-E with Shade', window_constr, shade_mat, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) double_low_e_between_shade = WindowConstructionShade( 'Double Low-E Between Shade', window_clear, shade_mat, 'Between') double_ext_shade = WindowConstructionShade( 'Double Outside Shade', window_clear, shade_mat, 'Interior') double_low_e_shade_dup = double_low_e_shade.duplicate() assert double_low_e_shade.identifier == 'Double Low-E with Shade' assert double_low_e_shade.window_construction == \ double_low_e_shade_dup.window_construction assert double_low_e_shade.shade_material == double_low_e_shade_dup.shade_material assert double_low_e_shade.shade_location == \ double_low_e_shade_dup.shade_location == 'Exterior' assert double_low_e_shade.control_type == \ double_low_e_shade_dup.control_type == 'OnIfHighSolarOnWindow' assert double_low_e_shade.setpoint == double_low_e_shade_dup.setpoint == 200 assert double_low_e_shade.schedule == double_low_e_shade_dup.schedule == sched assert len(double_low_e_shade.materials) == 4 assert len(double_low_e_shade.layers) == 4 assert len(double_low_e_shade.unique_materials) == 4 assert double_low_e_shade.r_value == double_low_e_shade.r_value == \ pytest.approx(0.41984, rel=1e-2) assert double_low_e_shade.u_value == double_low_e_shade.u_value == \ pytest.approx(2.3818, rel=1e-2) assert double_low_e_shade.u_factor == double_low_e_shade.u_factor == \ pytest.approx(1.69802, rel=1e-2) assert double_low_e_shade.r_factor == double_low_e_shade.r_factor == \ pytest.approx(0.588919, rel=1e-2) assert not double_low_e_shade.is_symmetric assert not double_low_e_shade.is_switchable_glazing assert double_low_e_shade.has_shade assert double_low_e_shade.inside_emissivity == \ double_low_e_shade.inside_emissivity == 0.84 assert double_low_e_shade.outside_emissivity == \ double_low_e_shade.outside_emissivity == 0.4 assert double_low_e_shade.thickness == \ double_low_e_shade.window_construction.thickness assert double_low_e_shade.glazing_count == 2 assert double_low_e_shade.gap_count == 1 assert double_low_e_between_shade.identifier == 'Double Low-E Between Shade' assert double_low_e_between_shade.shade_location == 'Between' assert double_low_e_between_shade.control_type == 'AlwaysOn' assert double_low_e_between_shade.setpoint is None assert double_low_e_between_shade.schedule is None assert len(double_low_e_between_shade.materials) == 5 assert len(double_low_e_between_shade.unique_materials) == 3 assert double_low_e_between_shade.is_symmetric assert double_low_e_between_shade.gap_count == 2 assert double_ext_shade.identifier == 'Double Outside Shade' assert len(double_ext_shade.materials) == 4 assert len(double_ext_shade.unique_materials) == 3
def test_shade_invalid(): """Test EnergyWindowMaterialShade objects with invalid properties.""" shade_mat = EnergyWindowMaterialShade('Diffusing Shade') with pytest.raises(TypeError): shade_mat.identifier = ['test_identifier'] with pytest.raises(AssertionError): shade_mat.thickness = -1 with pytest.raises(AssertionError): shade_mat.conductivity = -1 with pytest.raises(AssertionError): shade_mat.solar_transmittance = 2 with pytest.raises(AssertionError): shade_mat.solar_reflectance = 2 with pytest.raises(AssertionError): shade_mat.visible_transmittance = 2 with pytest.raises(AssertionError): shade_mat.visible_reflectance = 2 with pytest.raises(AssertionError): shade_mat.infrared_transmittance = 2 with pytest.raises(AssertionError): shade_mat.emissivity = 2 with pytest.raises(AssertionError): shade_mat.resistivity = -1 with pytest.raises(AssertionError): shade_mat.u_value = -1 with pytest.raises(AssertionError): shade_mat.r_value = -1
def material_window_shade(directory): shades = EnergyWindowMaterialShade('White Diffusing Roller Shade') dest_file = os.path.join(directory, 'material_window_shade.json') with open(dest_file, 'w') as fp: json.dump(shades.to_dict(), fp, indent=4)