diff --git a/bpeng/simulation/base.py b/bpeng/simulation/base.py index fd23cbf428cbbb037ba0a2c2b914ac1d1630eee1..799b8f9aca9574add08743a1a3e3cd5e2a9992f9 100644 --- a/bpeng/simulation/base.py +++ b/bpeng/simulation/base.py @@ -139,6 +139,8 @@ class BaseSim: Column name in building_shapefile DataFrame corresponding to number of units in building """ # Assert if columns taht will be used exist in building shapefile + print("assert building shapefile is formatted correctly") + assert buildingid_colname in building_shapefile, "Missing column {} in building shapefile"\ .format(buildingid_colname) assert cnstrct_yr_colname in building_shapefile, "Missing column {} in building shapefile"\ @@ -149,14 +151,18 @@ class BaseSim: .format(build_height_colname) assert num_floors_colname in building_shapefile, "Missing column {} in building shapefile"\ .format(num_floors_colname) + print("passed asserts") if num_units_colname not in building_shapefile: logging.warning("Missing number_of_units column in building shapefile. Required to add DHW object.") col_float = [buildingid_colname, cnstrct_yr_colname, build_height_colname, num_floors_colname] else: col_float = [buildingid_colname, cnstrct_yr_colname, build_height_colname, num_floors_colname, num_units_colname] + print("passed if/else") # Convert columns to float building_shapefile[col_float] = building_shapefile[col_float].astype(float) + + print("assert geometry data type") # Assert data type of geometry geom_type1 = building_shapefile[geometry_colname].apply(type).value_counts().index[0] assert geom_type1 == Polygon, 'Geometry in building shapefile is not ' \ @@ -172,6 +178,7 @@ class BaseSim: num_vert = building_shapefile[geometry_colname].apply(lambda x: len(x.exterior.coords)) assert (num_vert < 120).all(), "One or more building footprint geometry has more than 120 vertices" + print("second round of shapefile checks") # Perform same checks on shading building shapefile if building_shading_shapefile is not None: # Check if important columns exist in shading building shapefile @@ -218,6 +225,7 @@ class BaseSim: 'these buildings were deleted') building_shading_shapefile = building_shading_shapefile.drop(num_vert_too_big_index) + print("simulation base: load file starting") # Load starting idf file dir_path = os.path.dirname(os.path.abspath(__file__)) if idf_start_file is None: @@ -225,6 +233,7 @@ class BaseSim: else: idf_source = IDF(idf_start_file) + print("initialize sim base fields") self.idf = idf_source.copy() self.build_type = self.__class__.__name__ self.building_id = list(building_shapefile[buildingid_colname]) @@ -561,7 +570,7 @@ class BaseSim: def idf_creation(self, add_shading_analysis=False, window_to_wall_ratio=0.16, infiltration_value='Automatic', add_people=False, people_value='Automatic', add_equipment=False, equipment_value='Automatic', add_light=False, light_value='Automatic', solar_dist_method="FullExterior", output_table=False, - add_dhw=False): + add_dhw=False, u_values='Automatic'): """ Create EnergyPlus input IDF file from building shapefile. Default output variables (see output_var_default): @@ -617,6 +626,16 @@ class BaseSim: "FullExteriorWithReflections" "FullInteriorAndExteriorWithReflections" See EnergyPlus InputOutputReference documentation for more information + + u_values (dict mapping string -> float) + Specifies insulation level for following building elements: + External wall + Ground floor + Roof + Internal ceiling + Internal floor + Window + See bloclink/apps/envelope/models.py output_table (bool) Default to False: remove "OutputControl:Table:Style" object @@ -978,6 +997,29 @@ class BaseSim: self.idf.add_object("ZoneAirContaminantBalance, No;") self.idf.add_object("ZoneAirHeatBalanceAlgorithm, ThirdOrderBackwardDifference;") + # Added for U-Values + if u_values != 'Automatic': + print('u_values') + convert_to_eplus_name = { + 'u_ext_wall': 'AllExteriorWalls', + 'u_ground_floor': 'AllExteriorFloors', + 'u_roof': 'AllExteriorRoofs', + 'u_in_ceiling': 'AllInteriorCeilings', + 'u_in_floor': 'AllInteriorFloors', + 'u_window': 'AllExteriorWindows', + } + for key in convert_to_eplus_name: + ep_name = convert_to_eplus_name[key] + if key not in u_values: + continue + newIdfObj = '''SurfaceProperty:ConvectionCoefficients:MultipleSurface, + {}, ! - Surface Types + Outside, ! - Convection Coefficient 1 Location + Value, ! - Convection Coefficient 1 Type + {}; ! - Convection Coefficient 1'''.format(ep_name, u_values[key]) + print(newIdfObj) + self.idf.add_object(newIdfObj) + # Design Days add_dday(self.idf)