def test_simple_sys_init(): """Test initialization of EnergyWindowMaterialSimpleGlazSys and properties.""" lowe_sys = EnergyWindowMaterialSimpleGlazSys( 'Double Pane Low-e', 1.8, 0.35, 0.55) str(lowe_sys) # test the string representation of the material lowe_sys_dup = lowe_sys.duplicate() assert lowe_sys.identifier == lowe_sys_dup.identifier == 'Double Pane Low-e' assert lowe_sys.u_factor == lowe_sys_dup.u_factor == 1.8 assert lowe_sys.shgc == lowe_sys_dup.shgc == 0.35 assert lowe_sys.vt == lowe_sys_dup.vt == 0.55 assert lowe_sys.r_factor == lowe_sys_dup.r_factor == pytest.approx(1 / 1.8, rel=1e-3) assert lowe_sys.r_value == lowe_sys_dup.r_value == pytest.approx(0.387077, rel=1e-3) assert lowe_sys.u_value == lowe_sys_dup.u_value == pytest.approx(2.58346333, rel=1e-3)
def window_material_by_name(material_name): """Get an window material from the library given the material name. Args: material_name: A text string for the name of the material. """ try: # see if the material has already been loaded to a Python object return _idf_window_materials[material_name] except KeyError: # material likely needs to be loaded from standards data try: _mat_dict = _window_standards_dict[material_name] except KeyError: # material is nowhere to be found; raise an error raise ValueError( '"{}" was not found in the window energy material library.'. format(material_name)) # create the Python object from the standards gem dictionary if _mat_dict['material_type'] == 'StandardGlazing': _mat_obj = EnergyWindowMaterialGlazing.from_standards_dict(_mat_dict) elif _mat_dict['material_type'] == 'SimpleGlazing': _mat_obj = EnergyWindowMaterialSimpleGlazSys.from_standards_dict( _mat_dict) elif _mat_dict['material_type'] == 'Gas': _mat_obj = EnergyWindowMaterialGas.from_standards_dict(_mat_dict) else: raise ValueError( 'Standards gem material type "{}" is not recognized.'.format( _mat_dict['material_type'])) _mat_obj.lock() _idf_window_materials[ material_name] = _mat_obj # next time, it will be loaded faster return _mat_obj
def test_simple_sys_init_from_idf(): """Test initialization of EnergyWindowMaterialGlazing objects from strings.""" ep_str_1 = "WindowMaterial:SimpleGlazingSystem,\n" \ "Fixed Window 2.00-0.40-0.31, !- Name\n" \ "1.987, !- U-Factor {W/m2-K}\n" \ "0.45, !- Solar Heat Gain Coefficient\n" \ "0.35; !- Visible Transmittance" glaz_sys = EnergyWindowMaterialSimpleGlazSys.from_idf(ep_str_1) assert glaz_sys.name == 'Fixed Window 2.00-0.40-0.31' assert glaz_sys.u_factor == 1.987 assert glaz_sys.shgc == 0.45 assert glaz_sys.vt == 0.35
def create_EP_window_mat(_win_obj): """ Creates an E+ style material for the window based on the PHPP U-W-Installed Args: _win_obj (): The PHPP-Style window object Returns: mat: The window E+ Material """ # Material properties name = 'PHPP_MAT_{}'.format(_win_obj.name) u_factor = _win_obj.u_w_installed shgc = _win_obj.glazing.gValue t_vis = 0.6 # Create the material mat = EnergyWindowMaterialSimpleGlazSys( clean_and_id_ep_string(name), u_factor, shgc, t_vis) mat.display_name = name return mat
def test_simple_sys_to_from_standards_dict(): """Test the initialization of EnergyMaterial objects from standards gem.""" standards_dict = { "name": "U 0.52 SHGC 0.39 Simple Glazing", "material_type": "SimpleGlazing", "u_factor": 0.52, "solar_heat_gain_coefficient": 0.39, "visible_transmittance": 0.31 } mat_1 = EnergyWindowMaterialSimpleGlazSys.from_standards_dict( standards_dict) assert mat_1.name == 'U 0.52 SHGC 0.39 Simple Glazing' assert mat_1.u_factor == pytest.approx(0.52 * 5.678, rel=1e-3) assert mat_1.shgc == pytest.approx(0.39, rel=1e-2) assert mat_1.vt == pytest.approx(0.31, rel=1e-2)
def test_simple_sys_invalid(): """Test EnergyWindowMaterialGlazing objects with invalid properties.""" clear = EnergyWindowMaterialSimpleGlazSys('Clear Window', 5.5, 0.8) with pytest.raises(TypeError): clear.name = ['test_name'] with pytest.raises(AssertionError): clear.u_factor = 10 with pytest.raises(AssertionError): clear.shgc = 2 with pytest.raises(AssertionError): clear.vt = 2
def test_simple_sys_dict_methods(): """Test the to/from dict methods.""" clear = EnergyWindowMaterialSimpleGlazSys('Clear Window', 5.5, 0.8) material_dict = clear.to_dict() new_material = EnergyWindowMaterialSimpleGlazSys.from_dict(material_dict) assert material_dict == new_material.to_dict()
def test_simple_sys_defaults(): """Test the EnergyWindowMaterialGlazing default properties.""" clear = EnergyWindowMaterialSimpleGlazSys('Clear Window', 5.5, 0.8) assert clear.vt == 0.6
def material_window_glazing_system(directory): simple_sys = EnergyWindowMaterialSimpleGlazSys( 'Fixed Window 2.00 0.40 0.31', u_factor=1.98, shgc=0.4) dest_file = os.path.join(directory, 'material_window_glazing_system.json') with open(dest_file, 'w') as fp: json.dump(simple_sys.to_dict(), fp, indent=4)
ghenv.Component.Name = "HB Window Material" ghenv.Component.NickName = 'WindowMat' ghenv.Component.Message = '0.1.2' ghenv.Component.Category = 'HB-Energy' ghenv.Component.SubCategory = "1 :: Constructions" ghenv.Component.AdditionalHelpFromDocStrings = "5" try: # import the core honeybee dependencies from honeybee.typing import clean_and_id_ep_string except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the honeybee-energy dependencies from honeybee_energy.material.glazing import EnergyWindowMaterialSimpleGlazSys 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 _t_vis_ = 0.6 if _t_vis_ is None else _t_vis_ # create the material mat = EnergyWindowMaterialSimpleGlazSys(clean_and_id_ep_string(_name), _u_factor, _shgc, _t_vis_) mat.display_name = _name
ghenv.Component.Message = '1.5.0' ghenv.Component.Category = 'HB-Energy' ghenv.Component.SubCategory = '1 :: Constructions' ghenv.Component.AdditionalHelpFromDocStrings = '6' try: # import the core honeybee dependencies from honeybee.typing import clean_and_id_ep_string, clean_ep_string except ImportError as e: raise ImportError('\nFailed to import honeybee:\n\t{}'.format(e)) try: # import the honeybee-energy dependencies from honeybee_energy.material.glazing import EnergyWindowMaterialSimpleGlazSys 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 _t_vis_ = 0.6 if _t_vis_ is None else _t_vis_ name = clean_and_id_ep_string('WindowMaterial') if _name_ is None else \ clean_ep_string(_name_) # create the material mat = EnergyWindowMaterialSimpleGlazSys(name, _u_factor, _shgc, _t_vis_) if _name_ is not None: mat.display_name = _name_
def constructions_2004(model_json, climate_zone, output_file): """Convert a Model's constructions to be conformant with ASHRAE 90.1-2004 appendix G. This includes assigning a ConstructionSet that is compliant with Table 5.5 to all rooms in the model. \b Args: model_json: Full path to a Model JSON file. climate_zone: Text indicating the ASHRAE climate zone. This can be a single integer (in which case it is interpreted as A) or it can include the A, B, or C qualifier (eg. 3C). """ try: # re-serialize the Model to Python and get the glazing ratios with open(model_json) as json_file: data = json.load(json_file) model = Model.from_dict(data) w_area = model.exterior_wall_area r_area = model.exterior_roof_area wr = model.exterior_wall_aperture_area / w_area if w_area != 0 else 0 sr = model.exterior_skylight_aperture_area / r_area if r_area != 0 else 0 # get the base ConstructionSet from the standards library clean_cz = str(climate_zone)[0] constr_set_id = '2004::ClimateZone{}::SteelFramed'.format(clean_cz) base_set = construction_set_by_identifier(constr_set_id) # parse the CSV file with exceptions to the base construction set ex_file = os.path.join(os.path.dirname(__file__), 'data', 'ashrae_2004.csv') ex_data = csv_to_matrix(ex_file) ex_cz = clean_cz if climate_zone != '3C' else climate_zone ex_ratio = '100' for ratio in (40, 30, 20, 10): if wr < ratio / 100 + 0.001: ex_ratio = str(ratio) for row in ex_data: if row[0] == ex_cz and row[1] == ex_ratio: vert_except = [float(val) for val in row[2:]] break # change the constructions for fixed and operable windows si_ip_u = 5.678263337 fixed_id = 'U {} SHGC {} Fixed Glz'.format(vert_except[0], vert_except[2]) fixed_mat = EnergyWindowMaterialSimpleGlazSys(fixed_id, vert_except[0] * si_ip_u, vert_except[2]) fixed_constr = WindowConstruction(fixed_id.replace('Glz', 'Window'), [fixed_mat]) oper_id = 'U {} SHGC {} Operable Glz'.format(vert_except[1], vert_except[2]) oper_mat = EnergyWindowMaterialSimpleGlazSys(oper_id, vert_except[1] * si_ip_u, vert_except[2]) oper_constr = WindowConstruction(oper_id.replace('Glz', 'Window'), [oper_mat]) base_set.aperture_set.window_construction = fixed_constr base_set.aperture_set.operable_construction = oper_constr # change the construction for skylights if the ratio is greater than 2% if sr > 0.021: for row in ex_data: if row[0] == ex_cz and row[1] == 'sky_5': sky_except = [float(row[2]), float(row[4])] break sky_id = 'U {} SHGC {} Skylight Glz'.format( sky_except[0], sky_except[1]) sky_mat = EnergyWindowMaterialSimpleGlazSys( sky_id, sky_except[0] * si_ip_u, sky_except[1]) sky_constr = WindowConstruction(sky_id.replace('Glz', 'Window'), [sky_mat]) base_set.aperture_set.skylight_construction = sky_constr # remove child constructions ans assign the construction set to all rooms model.properties.energy.remove_child_constructions() for room in model.rooms: room.properties.energy.construction_set = base_set # write the Model JSON string output_file.write(json.dumps(model.to_dict())) except Exception as e: _logger.exception( 'Model baseline construction creation failed.\n{}'.format(e)) sys.exit(1) else: sys.exit(0)