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_window_construction_ec_init(): """Test the initialization of WindowConstructionShade objects with electrochromic.""" 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) tint_glass = EnergyWindowMaterialGlazing( 'Tinted Low-e Glass', 0.00318, 0.09, 0.359, 0.16, 0.207, 0, 0.84, 0.046578, 1.0) window_constr = WindowConstruction('Double Low-E', [lowe_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_ec = WindowConstructionShade( 'Double Low-E Inside EC', window_constr, tint_glass, 'Exterior', 'OnIfHighSolarOnWindow', 200, sched) double_low_e_between_ec = WindowConstructionShade( 'Double Low-E Between EC', window_constr, tint_glass, 'Between') double_low_e_ext_ec = WindowConstructionShade( 'Double Low-E Outside EC', window_constr, tint_glass, 'Interior') double_low_e_ec_dup = double_low_e_ec.duplicate() assert double_low_e_ec.identifier == 'Double Low-E Inside EC' assert double_low_e_ec.window_construction == \ double_low_e_ec_dup.window_construction assert double_low_e_ec.shade_material == double_low_e_ec_dup.shade_material assert double_low_e_ec.shade_location == \ double_low_e_ec_dup.shade_location == 'Exterior' assert double_low_e_ec.control_type == \ double_low_e_ec_dup.control_type == 'OnIfHighSolarOnWindow' assert double_low_e_ec.setpoint == double_low_e_ec_dup.setpoint == 200 assert double_low_e_ec.schedule == double_low_e_ec_dup.schedule == sched assert len(double_low_e_ec.materials) == 3 assert len(double_low_e_ec.layers) == 3 assert len(double_low_e_ec.unique_materials) == 4 assert not double_low_e_ec.is_symmetric assert double_low_e_ec.is_switchable_glazing assert double_low_e_ec.has_shade assert double_low_e_ec.thickness == \ double_low_e_ec.window_construction.thickness assert double_low_e_ec.glazing_count == 2 assert double_low_e_ec.gap_count == 1 assert double_low_e_between_ec.identifier == 'Double Low-E Between EC' assert double_low_e_between_ec.shade_location == 'Between' assert double_low_e_between_ec.control_type == 'AlwaysOn' assert double_low_e_between_ec.setpoint is None assert double_low_e_between_ec.schedule is None assert len(double_low_e_between_ec.materials) == 3 assert len(double_low_e_between_ec.unique_materials) == 4 assert not double_low_e_between_ec.is_symmetric assert double_low_e_between_ec.gap_count == 1 assert double_low_e_ext_ec.identifier == 'Double Low-E Outside EC' assert len(double_low_e_ext_ec.materials) == 3
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 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 dict_to_construction(constr_dict, raise_exception=True): """Get a Python object of any Construction from a dictionary. Args: constr_dict: A dictionary of any Honeybee energy construction. Note that this should be a non-abridged dictionary to be valid. raise_exception: Boolean to note whether an excpetion should be raised if the object is not identified as a construction. Default: True. Returns: A Python object derived from the input constr_dict. """ try: # get the type key from the dictionary constr_type = constr_dict['type'] except KeyError: raise ValueError('Construction dictionary lacks required "type" key.') if constr_type == 'OpaqueConstruction': return OpaqueConstruction.from_dict(constr_dict) elif constr_type == 'WindowConstruction': return WindowConstruction.from_dict(constr_dict) elif constr_type == 'WindowConstructionShade': return WindowConstructionShade.from_dict(constr_dict) elif constr_type == 'ShadeConstruction': return ShadeConstruction.from_dict(constr_dict) elif constr_type == 'AirBoundaryConstruction': return AirBoundaryConstruction.from_dict(constr_dict) elif raise_exception: raise ValueError( '{} is not a recognized energy Construction type'.format( constr_type))
def window_construction_by_identifier(construction_identifier): """Get an window construction from the library given the construction identifier. Args: construction_identifier: A text string for the identifier of the construction. """ try: return _window_constructions[construction_identifier] except KeyError: try: # search the extension data constr_dict = _window_constr_standards_dict[ construction_identifier] if constr_dict['type'] == 'WindowConstructionAbridged': mats = {} for mat in constr_dict['layers']: mats[mat] = _m.window_material_by_identifier(mat) return WindowConstruction.from_dict_abridged(constr_dict, mats) else: # WindowConstructionShade mats = {} for mat in constr_dict['window_construction']['layers']: mats[mat] = _m.window_material_by_identifier(mat) shd_mat = constr_dict['shade_material'] mats[shd_mat] = _m.window_material_by_identifier(shd_mat) try: sch_id = constr_dict['schedule'] schs = {sch_id: _s.schedule_by_identifier(sch_id)} except KeyError: # no schedule key provided schs = {} return WindowConstructionShade.from_dict_abridged( constr_dict, mats, schs) except KeyError: # construction is nowhere to be found; raise an error raise ValueError( '"{}" was not found in the window energy construction library.' .format(construction_identifier))
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_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()
def dict_abridged_to_construction(constr_dict, materials, schedules, raise_exception=True): """Get a Python object of any Construction from an abridged dictionary. Args: constr_dict: An abridged dictionary of any Honeybee energy construction. materials: Dictionary of all material objects that might be used in the construction with the material identifiers as the keys. schedules: Dictionary of all schedule objects that might be used in the construction with the schedule identifiers as the keys. raise_exception: Boolean to note whether an excpetion should be raised if the object is not identified as a construction. Default: True. Returns: A Python object derived from the input constr_dict. """ try: # get the type key from the dictionary constr_type = constr_dict['type'] except KeyError: raise ValueError('Construction dictionary lacks required "type" key.') if constr_type == 'OpaqueConstructionAbridged': return OpaqueConstruction.from_dict_abridged(constr_dict, materials) elif constr_type == 'WindowConstructionAbridged': return WindowConstruction.from_dict_abridged(constr_dict, materials) elif constr_type == 'WindowConstructionShade': return WindowConstructionShade.from_dict_abridged( constr_dict, materials, schedules) elif constr_type == 'ShadeConstruction': return ShadeConstruction.from_dict(constr_dict) elif constr_type == 'AirBoundaryConstructionAbridged': return AirBoundaryConstruction.from_dict_abridged( constr_dict, schedules) elif constr_type == 'AirBoundaryConstruction': # special case for ConstructionSet return AirBoundaryConstruction.from_dict(constr_dict) elif raise_exception: raise ValueError( '{} is not a recognized energy Construction type'.format( constr_type))
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_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
'OnNightIfLowInsideTempAndOffDay': 'OnNightIfLowInsideTempAndOffDay', 'OnNightIfHeatingAndOffDay': 'OnNightIfHeatingAndOffDay' } if all_required_inputs(ghenv.Component): # set default values constr_id = clean_and_id_ep_string('ShadedWindowConstruction') if _name_ is None else \ clean_ep_string(_name_) _shd_location_ = 'Interior' if _shd_location_ is None else _shd_location_.title( ) _control_type_ = 'AlwaysOn' if _control_type_ is None \ else CONTROL_TYPES[_control_type_] # get objects from the library if they are strings if isinstance(_win_constr, str): win_con = window_construction_by_identifier(_win_constr) # duplicate and rename to avoid having the same construction name in one model _win_constr = win_con.duplicate() _win_constr.identifier = '{}_Unshaded'.format(constr_id) if isinstance(_shd_material, str): _shd_material = window_material_by_identifier(_shd_material) if isinstance(schedule_, str): schedule_ = schedule_by_identifier(schedule_) # create the construction object constr = WindowConstructionShade(constr_id, _win_constr, _shd_material, _shd_location_, _control_type_, setpoint_, schedule_) if _name_ is not None: constr.display_name = _name_