def test_blind_dict_methods(): """Test the to/from dict methods.""" shade_mat = EnergyWindowMaterialBlind('Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4, 0.05, 0.45, 0, 0.95, 0.1, 1) material_dict = shade_mat.to_dict() new_material = EnergyWindowMaterialBlind.from_dict(material_dict) assert material_dict == new_material.to_dict()
def test_window_construction_init_blind(): """Test the initalization of WindowConstruction objects with blinds.""" 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 = EnergyWindowMaterialBlind('Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4, 0.05, 0.45, 0, 0.95, 0.1, 1) 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(1.26296, 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.416379, 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(1.2089, rel=1e-2)
def construction_window_blinds(directory): blinds = EnergyWindowMaterialBlind('Generic Aluminium Blinds') window_with_blinds = WindowConstruction( 'Triple Pane Argon', [lowe_glass, argon_gap, lowe_glass, blinds]) dest_file = os.path.join(directory, 'construction_window_blinds.json') with open(dest_file, 'w') as fp: json.dump(window_with_blinds.to_dict(abridged=True), fp, indent=4)
def test_blind_from_idf(): """Test the initalization of shade material objects from EnergyPlus strings.""" ep_str_1 = "WindowMaterial:Blind,\n" \ "Default Shade, !- Name\n" \ "Horizontal, !- Slat Orientation\n" \ "0.04, !- Slat Width {m}\n" \ "0.04, !- Slat Separation {m}\n" \ "0.00025, !- Slat Thickness {m}\n" \ "90.0, !- Slat Angle {deg}\n" \ "221, !- Slat Conductivity {W/m-K}\n" \ "0, !- Slat Beam Solar Transmittance\n" \ "0.65, !- Front Side Slat Beam Solar Reflectance\n" \ "0.65, !- Back Side Slat Beam Solar Reflectance\n" \ "0, !- Slat Diffuse Solar Transmittance\n" \ "0.65, !- Front Side Slat Diffuse Solar Reflectance\n" \ "0.65, !- Back Side Slat Diffuse Solar Reflectance\n" \ "0, !- Slat Beam Visible Transmittance\n" \ "0.65, !- Front Side Slat Beam Visible Reflectance\n" \ "0.65, !- Back Side Slat Beam Visible Reflectance\n" \ "0, !- Slat Diffuse Visible Transmittance\n" \ "0.65, !- Front Side Slat Diffuse Visible Reflectance\n" \ "0.65, !- Back Side Slat Diffuse Visible Reflectance\n" \ "0, !- Slat Infrared Hemispherical Transmittance\n" \ "0.9, !- Front Side Slat Infrared Hemispherical Emissivity\n" \ "0.9, !- Back Side Slat Infrared Hemispherical Emissivity\n" \ "0.03, !- Blind to Glass Distance {m}\n" \ "1.0, !- Blind Top Opening Multiplier\n" \ "1.0, !- Blind Bottom Opening Multiplier\n" \ "1.0, !- Blind Left Side Opening Multiplier\n" \ "1.0, !- Blind Right Side Opening Multiplier\n" \ "0, !- Minimum Slat Angle {deg}\n" \ "180; !- Maximum Slat Angle {deg}" shade_mat = EnergyWindowMaterialBlind.from_idf(ep_str_1) assert shade_mat.slat_orientation == 'Horizontal' assert shade_mat.slat_width == 0.04 assert shade_mat.slat_separation == 0.04 assert shade_mat.slat_thickness == 0.00025 assert shade_mat.slat_angle == 90 assert shade_mat.slat_conductivity == 221 assert shade_mat.beam_solar_transmittance == 0 assert shade_mat.beam_solar_reflectance == 0.65 assert shade_mat.beam_solar_reflectance_back == 0.65 assert shade_mat.diffuse_solar_transmittance == 0 assert shade_mat.diffuse_solar_reflectance == 0.65 assert shade_mat.diffuse_solar_reflectance_back == 0.65 assert shade_mat.beam_visible_transmittance == 0 assert shade_mat.beam_visible_reflectance == 0.65 assert shade_mat.beam_visible_reflectance_back == 0.65 assert shade_mat.diffuse_visible_transmittance == 0 assert shade_mat.diffuse_visible_reflectance == 0.65 assert shade_mat.diffuse_visible_reflectance_back == 0.65 assert shade_mat.infrared_transmittance == 0 assert shade_mat.emissivity == 0.9 assert shade_mat.emissivity_back == 0.9 assert shade_mat.distance_to_glass == 0.03 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
def test_blind_defaults(): """Test the EnergyWindowMaterialBlind default properties.""" shade_mat = EnergyWindowMaterialBlind('Metalic Blind') assert shade_mat.slat_orientation == 'Horizontal' assert shade_mat.slat_width == 0.025 assert shade_mat.slat_separation == 0.01875 assert shade_mat.slat_thickness == 0.001 assert shade_mat.slat_angle == 45 assert shade_mat.slat_conductivity == 221 assert shade_mat.beam_solar_transmittance == 0 assert shade_mat.beam_solar_reflectance == 0.5 assert shade_mat.beam_solar_reflectance_back == 0.5 assert shade_mat.diffuse_solar_transmittance == 0 assert shade_mat.diffuse_solar_reflectance == 0.5 assert shade_mat.diffuse_solar_reflectance_back == 0.5 assert shade_mat.beam_visible_transmittance == 0 assert shade_mat.beam_visible_reflectance == 0.5 assert shade_mat.beam_visible_reflectance_back == 0.5 assert shade_mat.diffuse_visible_transmittance == 0 assert shade_mat.diffuse_visible_reflectance == 0.5 assert shade_mat.diffuse_visible_reflectance_back == 0.5 assert shade_mat.infrared_transmittance == 0 assert shade_mat.emissivity == 0.9 assert shade_mat.emissivity_back == 0.9 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
def construction_window_blinds(directory): shade_mat = EnergyWindowMaterialBlind( 'Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4, 0.05, 0.45, 0, 0.95, 0.1, 1) window_constr = WindowConstruction('Double Low-E', [lowe_glass, argon_gap, clear_glass]) window_with_blinds = WindowConstructionShade( 'Double Low-E Outside Shade', window_constr, shade_mat, 'Interior') dest_file = os.path.join(directory, 'construction_window_blinds.json') with open(dest_file, 'w') as fp: json.dump(window_with_blinds.to_dict(abridged=True), fp, indent=4)
def test_blind_init(): """Test the initalization of blind material objects and basic properties.""" shade_mat = EnergyWindowMaterialBlind('Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4, 0.05, 0.45, 0, 0.95, 0.1, 1) str(shade_mat) # test the string representation of the material shade_dup = shade_mat.duplicate() assert shade_mat.name == shade_dup.name == 'Plastic Blind' assert shade_mat.slat_orientation == shade_dup.slat_orientation == 'Vertical' assert shade_mat.slat_width == shade_dup.slat_width == 0.025 assert shade_mat.slat_separation == shade_dup.slat_separation == 0.01875 assert shade_mat.slat_thickness == shade_dup.slat_thickness == 0.003 assert shade_mat.slat_angle == shade_dup.slat_angle == 90 assert shade_mat.slat_conductivity == shade_dup.slat_conductivity == 0.2 assert shade_mat.beam_solar_transmittance == shade_dup.beam_solar_transmittance == 0.05 assert shade_mat.beam_solar_reflectance == shade_dup.beam_solar_reflectance == 0.4 assert shade_mat.beam_solar_reflectance_back == shade_dup.beam_solar_reflectance_back == 0.4 assert shade_mat.diffuse_solar_transmittance == shade_dup.diffuse_solar_transmittance == 0.05 assert shade_mat.diffuse_solar_reflectance == shade_dup.diffuse_solar_reflectance == 0.4 assert shade_mat.diffuse_solar_reflectance_back == shade_dup.diffuse_solar_reflectance_back == 0.4 assert shade_mat.beam_visible_transmittance == shade_dup.beam_visible_transmittance == 0.05 assert shade_mat.beam_visible_reflectance == shade_dup.beam_visible_reflectance == 0.45 assert shade_mat.beam_visible_reflectance_back == shade_dup.beam_visible_reflectance_back == 0.45 assert shade_mat.diffuse_visible_transmittance == shade_dup.diffuse_visible_transmittance == 0.05 assert shade_mat.diffuse_visible_reflectance == shade_dup.diffuse_visible_reflectance == 0.45 assert shade_mat.diffuse_visible_reflectance_back == shade_dup.diffuse_visible_reflectance_back == 0.45 assert shade_mat.infrared_transmittance == shade_dup.infrared_transmittance == 0 assert shade_mat.emissivity == shade_dup.emissivity == 0.95 assert shade_mat.emissivity_back == shade_dup.emissivity_back == 0.95 assert shade_mat.distance_to_glass == shade_dup.distance_to_glass == 0.1 assert shade_mat.top_opening_multiplier == shade_dup.top_opening_multiplier == 1 assert shade_mat.bottom_opening_multiplier == shade_dup.bottom_opening_multiplier == 1 assert shade_mat.left_opening_multiplier == shade_dup.left_opening_multiplier == 1 assert shade_mat.right_opening_multiplier == shade_dup.right_opening_multiplier == 1 assert shade_mat.minimum_slat_angle == shade_dup.minimum_slat_angle == 0 assert shade_mat.maximum_slat_angle == shade_dup.maximum_slat_angle == 180 assert shade_mat.slat_resistivity == shade_dup.slat_resistivity == 1 / 0.2 assert shade_mat.u_value == shade_dup.u_value == 0.2 / 0.003 assert shade_mat.r_value == shade_dup.r_value == 0.003 / 0.2
def test_window_construction_blind_init(): """Test the initialization of WindowConstructionShade objects with blinds.""" 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.03) shade_mat = EnergyWindowMaterialBlind( 'Plastic Blind', 'Vertical', 0.025, 0.01875, 0.003, 90, 0.2, 0.05, 0.4, 0.05, 0.45, 0, 0.95, 0.1, 1) 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]) double_low_e_shade = WindowConstructionShade( 'Double Low-E with Blind', window_constr, shade_mat, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) double_low_e_between_shade = WindowConstructionShade( 'Double Low-E Between Blind', window_clear, shade_mat, 'Between') double_low_e_ext_shade = WindowConstructionShade( 'Double Low-E Outside Blind', window_constr, shade_mat, 'Interior') double_low_e_shade_dup = double_low_e_shade.duplicate() assert double_low_e_shade.identifier == 'Double Low-E with Blind' 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 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.95 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 Blind' 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_low_e_ext_shade.identifier == 'Double Low-E Outside Blind' assert len(double_low_e_ext_shade.materials) == 4
def test_blind_invalid(): """Test EnergyWindowMaterialShade objects with invalid properties.""" shade_mat = EnergyWindowMaterialBlind('Metalic Blind') with pytest.raises(TypeError): shade_mat.identifier = ['test_identifier'] with pytest.raises(AssertionError): shade_mat.slat_orientation = 'Diagonal' with pytest.raises(AssertionError): shade_mat.slat_width = 2 with pytest.raises(AssertionError): shade_mat.slat_separation = 2 with pytest.raises(AssertionError): shade_mat.slat_thickness = -1 with pytest.raises(AssertionError): shade_mat.slat_angle = 270 with pytest.raises(AssertionError): shade_mat.slat_conductivity = -1 with pytest.raises(AssertionError): shade_mat.beam_solar_transmittance = 2 with pytest.raises(AssertionError): shade_mat.beam_solar_reflectance = 2 with pytest.raises(AssertionError): shade_mat.beam_visible_transmittance = 2 with pytest.raises(AssertionError): shade_mat.beam_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.slat_resistivity = -1 with pytest.raises(AssertionError): shade_mat.u_value = -1 with pytest.raises(AssertionError): shade_mat.r_value = -1
def material_window_blind(directory): blinds = EnergyWindowMaterialBlind('Generic Aluminium Blinds') dest_file = os.path.join(directory, 'material_window_blind.json') with open(dest_file, 'w') as fp: json.dump(blinds.to_dict(), fp, indent=4)
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 orientation = 'Vertical' if _vertical_ else 'Horizontal' _slat_width_ = 0.025 if _slat_width_ is None else _slat_width_ _slat_separation_ = 0.01875 if _slat_separation_ is None else _slat_separation_ _slat_thickness_ = 0.001 if _slat_thickness_ is None else _slat_thickness_ _slat_angle_ = 45 if _slat_angle_ is None else _slat_angle_ _conductivity_ = 221 if _conductivity_ is None else _conductivity_ _transmittance_ = 0 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_ _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_ name = clean_and_id_ep_string('BlindMaterial') if _name_ is None else \ clean_ep_string(_name_) # create the material mat = EnergyWindowMaterialBlind( name, orientation, _slat_width_, _slat_separation_, _slat_thickness_, _slat_angle_, _conductivity_, _transmittance_, _reflectance_, _transmittance_, _reflectance_, _t_infrared_, _emissivity_, _dist_to_glass_, _open_mult_) if _name_ is not None: mat.display_name = _name_
def test_dict_to_object_material(): """Test the dict_to_object method with EnergyWindowMaterialBlind objects.""" material_obj = EnergyWindowMaterialBlind('Test Blind') material_dict = material_obj.to_dict() new_material = dict_to_object(material_dict) assert isinstance(new_material, EnergyWindowMaterialBlind)