def import_building_from_excel(project, building_name, construction_age, path_to_excel, sheet_names): """ Import building data from excel, convert it via the respective zoning and feed it to teasers logic classes. Pay attention to hard coded parts, which are marked. Parameters ---------- project: Project() TEASER instance of Project building_name: str name of building to be set in the project construction_age: int [y] construction age of the building path_to_excel: str path to excel file to be imported sheet_names: str or list sheet names which shall be imported return data: pandas.DataFrame zoned DataFrame which is finally used to parametrize the teaser classes return project: Project() TEASER instance of Project filled with the imported building data """ def warn_constructiontype(element): """Generic warning function""" if element.construction_type is None: warnings.warn( 'In zone "%s" the %s construction "%s" could not be loaded from the TypeBuildingElements.json, ' "an error will occur due to missing data for calculation." "Check for spelling and the correct combination of building age and construction type." "Here is the list of faulty entries:\n%s" "\nThese entries can easily be found checking the stated index in the produced ZonedInput.xlsx" % ( group["zone"].iloc[0], element.name, group["OuterWallConstruction"].iloc[0], group, )) bldg = Building(parent=project) bldg.name = building_name bldg.year_of_construction = construction_age bldg.with_ahu = True # HardCodedInput if bldg.with_ahu is True: bldg.central_ahu.heat_recovery = True # HardCodedInput bldg.central_ahu.efficiency_recovery = 0.35 # HardCodedInput bldg.central_ahu.temperature_profile = 25 * [273.15 + 18 ] # HardCodedInput bldg.central_ahu.min_relative_humidity_profile = 25 * [ 0 ] # HardCodedInput bldg.central_ahu.max_relative_humidity_profile = 25 * [ 1 ] # HardCodedInput bldg.central_ahu.v_flow_profile = 25 * [1] # HardCodedInput # Parameters that need hard coding in teasers logic classes # 1. "use_set_back" needs hard coding at aixlib.py in the init; defines # if the in the useconditions stated # heating_time with the respective set_back_temp should be applied. # use_set_back = false -> all hours of the day # have same set_temp_heat actual value: use_set_back = Check your current version! # 2. HeaterOn, CoolerOn, hHeat, lCool, etc. can be hard coded in the text # file # "teaser / data / output / modelicatemplate / AixLib / # AixLib_ThermalZoneRecord_TwoElement" # actual changes: Check your current version! # Parameters to be set for each and every zone (#HardCodedInput) # ----------------------------- out_wall_tilt = 90 window_tilt = 90 ground_floor_tilt = 0 floor_tilt = 0 ceiling_tilt = 0 rooftop_tilt = 0 ground_floor_orientation = -2 floor_orientation = -2 rooftop_orientation = -1 ceiling_orientation = -1 # ----------------------------- # load_building_data from excel_to_pandas DataFrame: data = import_data(path_to_excel, sheet_names) # informative print usage_types = get_list_of_present_entries(data["UsageType"]) print("List of present usage_types in the original Data set: \n%s" % usage_types) # define the zoning methodology/function data = zoning_example(data) # informative print usage_types = get_list_of_present_entries(data["Zone"]) print("List of zones after the zoning is applied: \n%s" % usage_types) # aggregate all rooms of each zone and for each set general parameter, # boundary conditions # and parameter regarding the building physics zones = data.groupby(["Zone"]) for name, zone in zones: # Block: Thermal zone (general parameter) tz = ThermalZone(parent=bldg) tz.name = str(name) tz.area = zone["NetArea[m²]"].sum() # room vice calculation of volume plus summing those tz.volume = (np.array(zone["NetArea[m²]"]) * np.array(zone["HeatedRoomHeight[m]"])).sum() # Block: Boundary Conditions # load UsageOperationTime, Lighting, RoomClimate and InternalGains # from the "UseCondition.json" tz.use_conditions = UseConditions(parent=tz) tz.use_conditions.load_use_conditions(zone["Zone"].iloc[0], project.data) # Block: Building Physics # Grouping by orientation and construction type # aggregating and feeding to the teaser logic classes grouped = zone.groupby( ["OuterWallOrientation[°]", "OuterWallConstruction"]) for name, group in grouped: # looping through a groupby object automatically discards the # groups where one of the attributes is nan # additionally check for strings, since the value must be of type # int or float if not isinstance(group["OuterWallOrientation[°]"].iloc[0], str): out_wall = OuterWall(parent=tz) out_wall.name = ( "outer_wall_" + str(int(group["OuterWallOrientation[°]"].iloc[0])) + "_" + str(group["OuterWallConstruction"].iloc[0])) out_wall.area = group["OuterWallArea[m²]"].sum() out_wall.tilt = out_wall_tilt out_wall.orientation = group["OuterWallOrientation[°]"].iloc[0] # load wall properties from "TypeBuildingElements.json" out_wall.load_type_element( year=bldg.year_of_construction, construction=group["OuterWallConstruction"].iloc[0], ) warn_constructiontype(out_wall) else: warnings.warn( 'In zone "%s" the OuterWallOrientation "%s" is ' "neither float nor int, " "hence this building element is not added.\nHere is the " "list of faulty entries:\n%s" "\n These entries can easily be found checking the stated " "index in the produced ZonedInput.xlsx" % ( group["Zone"].iloc[0], group["OuterWallOrientation[°]"].iloc[0], group, )) grouped = zone.groupby(["WindowOrientation[°]", "WindowConstruction"]) for name, group in grouped: # looping through a groupby object automatically discards the # groups where one of the attributes is nan # additionally check for strings, since the value must be of type # int or float if not isinstance(group["OuterWallOrientation[°]"].iloc[0], str): window = Window(parent=tz) window.name = ( "window_" + str(int(group["WindowOrientation[°]"].iloc[0])) + "_" + str(group["WindowConstruction"].iloc[0])) window.area = group["WindowArea[m²]"].sum() window.tilt = window_tilt window.orientation = group["WindowOrientation[°]"].iloc[0] # load wall properties from "TypeBuildingElements.json" window.load_type_element( year=bldg.year_of_construction, construction=group["WindowConstruction"].iloc[0], ) warn_constructiontype(window) else: warnings.warn( 'In zone "%s" the window orientation "%s" is neither ' "float nor int, " "hence this building element is not added. Here is the " "list of faulty entries:\n%s" "\nThese entries can easily be found checking the stated " "index in the produced ZonedInput.xlsx" % ( group["Zone"].iloc[0], group["WindowOrientation[°]"].iloc[0], group, )) grouped = zone.groupby(["IsGroundFloor", "FloorConstruction"]) for name, group in grouped: if group["NetArea[m²]"].sum() != 0: # to avoid devision by 0 if group["IsGroundFloor"].iloc[0] == 1: ground_floor = GroundFloor(parent=tz) ground_floor.name = "ground_floor" + str( group["FloorConstruction"].iloc[0]) ground_floor.area = group["NetArea[m²]"].sum() ground_floor.tilt = ground_floor_tilt ground_floor.orientation = ground_floor_orientation # load wall properties from "TypeBuildingElements.json" ground_floor.load_type_element( year=bldg.year_of_construction, construction=group["FloorConstruction"].iloc[0], ) warn_constructiontype(ground_floor) elif group["IsGroundFloor"].iloc[0] == 0: floor = Floor(parent=tz) floor.name = "floor" + str( group["FloorConstruction"].iloc[0]) floor.area = group["NetArea[m²]"].sum() / 2 # only half of # the floor belongs to this story floor.tilt = floor_tilt floor.orientation = floor_orientation # load wall properties from "TypeBuildingElements.json" floor.load_type_element( year=bldg.year_of_construction, construction=group["FloorConstruction"].iloc[0], ) warn_constructiontype(floor) else: warnings.warn( "Values for IsGroundFloor have to be either 0 or 1, " "for no or yes respectively") else: warnings.warn( 'zone "%s" with IsGroundFloor "%s" and construction ' 'type "%s" ' "has no floor nor groundfloor, since the area equals 0." % ( group["Zone"].iloc[0], group["IsGroundFloor"].iloc[0], group["FloorConstruction"].iloc[0], )) grouped = zone.groupby(["IsRooftop", "CeilingConstruction"]) for name, group in grouped: if group["NetArea[m²]"].sum() != 0: # to avoid devision by 0 if group["IsRooftop"].iloc[0] == 1: rooftop = Rooftop(parent=tz) rooftop.name = "rooftop" + str( group["CeilingConstruction"].iloc[0]) rooftop.area = group["NetArea[m²]"].sum( ) # sum up area of respective # rooftop parts rooftop.tilt = rooftop_tilt rooftop.orientation = rooftop_orientation # load wall properties from "TypeBuildingElements.json" rooftop.load_type_element( year=bldg.year_of_construction, construction=group["CeilingConstruction"].iloc[0], ) warn_constructiontype(rooftop) elif group["IsRooftop"].iloc[0] == 0: ceiling = Ceiling(parent=tz) ceiling.name = "ceiling" + str( group["CeilingConstruction"].iloc[0]) ceiling.area = group["NetArea[m²]"].sum() / 2 # only half # of the ceiling belongs to a story, # the other half to the above ceiling.tilt = ceiling_tilt ceiling.orientation = ceiling_orientation # load wall properties from "TypeBuildingElements.json" ceiling.load_type_element( year=bldg.year_of_construction, construction=group["CeilingConstruction"].iloc[0], ) warn_constructiontype(ceiling) else: warnings.warn( "Values for IsRooftop have to be either 0 or 1, " "for no or yes respectively") else: warnings.warn( 'zone "%s" with IsRooftop "%s" and construction type ' '"%s" ' "has no ceiling nor rooftop, since the area equals 0." % ( group["Zone"].iloc[0], group["IsRooftop"].iloc[0], group["CeilingConstruction"].iloc[0], )) grouped = zone.groupby(["InnerWallConstruction"]) for name, group in grouped: if group["InnerWallArea[m²]"].sum() != 0: # to avoid devision by 0 in_wall = InnerWall(parent=tz) in_wall.name = "inner_wall" + str( group["InnerWallConstruction"].iloc[0]) in_wall.area = group["InnerWallArea[m²]"].sum() / 2 # only # half of the wall belongs to each room, # the other half to the adjacent # load wall properties from "TypeBuildingElements.json" in_wall.load_type_element( year=bldg.year_of_construction, construction=group["InnerWallConstruction"].iloc[0], ) warn_constructiontype(in_wall) else: warnings.warn( 'zone "%s" with inner wall construction "%s" has no ' "inner walls, since area = 0." % (group["Zone"].iloc[0], group["InnerWallConstructio" "n"].iloc[0])) # Block: AHU and infiltration #Attention hard coding # set the supply volume flow of the AHU per zone ahu_dict = { "Bedroom": [15.778, 15.778], "Corridorsinthegeneralcarearea": [5.2941, 5.2941], "Examinationortreatmentroom": [15.743, 15.743], "MeetingConferenceseminar": [16.036, 16.036], "Stocktechnicalequipmentarchives": [20.484, 20.484], "WCandsanitaryroomsinnonresidentialbuildings": [27.692, 27.692], } _i = 0 for key in ahu_dict: if tz.name == key: tz.use_conditions.min_ahu = ahu_dict[key][0] tz.use_conditions.max_ahu = ahu_dict[key][1] _i = 1 if _i == 0: warnings.warn( "The zone %s could not be found in your ahu_dict. Hence, " "no AHU flow is defined. The default value is " "0 (min_ahu = 0; max_ahu=0" % tz.name) return project, data
def from_scratch( number_of_elements, save=False, path=utilities.get_default_path()): """This function creates the test room from scratch. Notes: The standard defines an solar absorption coefficient for interior surfaces of 0.6. We do not consider this, but we could by multiplying the solar radiation after the window by 0.6. Parameters ---------- number_of_elements: int Number of elements of model path: str (optional) Path where Project should be stored as .teaserXML save: bool (optional) True if Project should be stored as .teaserXML at path Returns ------- prj: Project Project that contains the building with the test room """ prj = Project(load_data=True) prj.name = "ASHRAE140Verification" bldg = Building(parent=prj) bldg.name = "TestBuilding" tz = ThermalZone(parent=bldg) tz.name = "TestRoom900" tz.area = 8.0 * 6.0 tz.volume = tz.area * 2.7 tz.infiltration_rate = 0.41 tz.use_conditions = BoundaryConditions(parent=tz) roof = Rooftop(parent=tz) roof.name = "Roof" roof.area = 8.0 * 6.0 roof.orientation = -1.0 roof.tilt = 0.0 roof.inner_convection = 1 roof.outer_convection = 24.67 roof.inner_radiation = 5.13 roof.outer_radiation = 4.63 layer_r1 = Layer(parent=roof, id=0) layer_r1.thickness = 0.01 material_r1 = Material(layer_r1) material_r1.name = "Plasterboard" material_r1.density = 950.0 material_r1.heat_capac = 840.0 / 1000 material_r1.thermal_conduc = 0.16 material_r1.ir_emissivity = 0.9 layer_r2 = Layer(parent=roof, id=1) layer_r2.thickness = 0.1118 material_r2 = Material(layer_r2) material_r2.name = "Fiberglass" material_r2.density = 12 material_r2.heat_capac = 840 / 1000 material_r2.thermal_conduc = 0.04 layer_r3 = Layer(parent=roof, id=2) layer_r3.thickness = 0.019 material_r3 = Material(layer_r3) material_r3.name = "Roofdeck" material_r3.density = 530 material_r3.heat_capac = 900 / 1000 material_r3.thermal_conduc = 0.14 material_r3.solar_absorp = 0.6 material_r3.ir_emissivity = 0.9 out_wall_north = OuterWall(parent=tz) out_wall_north.name = "OuterWallNorth" out_wall_north.area = 8.0 * 2.7 out_wall_north.orientation = 0.0 out_wall_north.tilt = 90.0 out_wall_north.inner_convection = 3.16 out_wall_north.outer_convection = 24.67 out_wall_north.inner_radiation = 5.13 out_wall_north.outer_radiation = 4.63 layer_own1 = Layer(parent=out_wall_north, id=0) layer_own1.thickness = 0.1 material_own1 = Material(layer_own1) material_own1.name = "Concrete" material_own1.density = 1400.0 material_own1.heat_capac = 1000 / 1000 material_own1.thermal_conduc = 0.51 material_own1.ir_emissivity = 0.9 layer_own2 = Layer(parent=out_wall_north, id=1) layer_own2.thickness = 0.062 material_own2 = Material(layer_own2) material_own2.name = "FoamInsulation" material_own2.density = 10 material_own2.heat_capac = 1400 / 1000 material_own2.thermal_conduc = 0.04 layer_own3 = Layer(parent=out_wall_north, id=2) layer_own3.thickness = 0.009 material_own3 = Material(layer_own3) material_own3.name = "WoodSiding" material_own3.density = 530 material_own3.heat_capac = 900 / 1000 material_own3.thermal_conduc = 0.14 material_own3.solar_absorp = 0.6 material_own3.ir_emissivity = 0.9 out_wall_east = OuterWall(parent=tz) out_wall_east.name = "OuterWallEast" out_wall_east.area = 6.0 * 2.7 out_wall_east.orientation = 90.0 out_wall_east.tilt = 90.0 out_wall_east.inner_convection = 3.16 out_wall_east.outer_convection = 24.67 out_wall_east.inner_radiation = 5.13 out_wall_east.outer_radiation = 4.63 layer_owe1 = Layer(parent=out_wall_east, id=0) layer_owe1.thickness = 0.1 material_owe1 = Material(layer_owe1) material_owe1.name = "Concrete" material_owe1.density = 1400.0 material_owe1.heat_capac = 1000 / 1000 material_owe1.thermal_conduc = 0.51 material_owe1.ir_emissivity = 0.9 layer_owe2 = Layer(parent=out_wall_east, id=1) layer_owe2.thickness = 0.062 material_owe2 = Material(layer_owe2) material_owe2.name = "FoamInsulation" material_owe2.density = 10 material_owe2.heat_capac = 1400 / 1000 material_owe2.thermal_conduc = 0.04 layer_owe3 = Layer(parent=out_wall_east, id=2) layer_owe3.thickness = 0.009 material_owe3 = Material(layer_owe3) material_owe3.name = "WoodSiding" material_owe3.density = 530 material_owe3.heat_capac = 900 / 1000 material_owe3.thermal_conduc = 0.14 material_owe3.solar_absorp = 0.6 material_owe3.ir_emissivity = 0.9 out_wall_south = OuterWall(parent=tz) out_wall_south.name = "OuterWallSouth" out_wall_south.area = (8.0 * 2.7) - 2 * (3 * 2) # minus two windows out_wall_south.orientation = 180.0 out_wall_south.tilt = 90.0 out_wall_south.inner_convection = 3.16 out_wall_south.outer_convection = 24.67 out_wall_south.inner_radiation = 5.13 out_wall_south.outer_radiation = 4.63 layer_ows1 = Layer(parent=out_wall_south, id=0) layer_ows1.thickness = 0.1 material_ows1 = Material(layer_ows1) material_ows1.name = "Concrete" material_ows1.density = 1400.0 material_ows1.heat_capac = 1000.0 / 1000 material_ows1.thermal_conduc = 0.51 material_ows1.ir_emissivity = 0.9 layer_ows2 = Layer(parent=out_wall_south, id=1) layer_ows2.thickness = 0.062 material_ows2 = Material(layer_ows2) material_ows2.name = "FoamInsulation" material_ows2.density = 10 material_ows2.heat_capac = 1400 / 1000 material_ows2.thermal_conduc = 0.04 layer_ows3 = Layer(parent=out_wall_south, id=2) layer_ows3.thickness = 0.009 material_ows3 = Material(layer_ows3) material_ows3.name = "WoodSiding" material_ows3.density = 530 material_ows3.heat_capac = 900 / 1000 material_ows3.thermal_conduc = 0.14 material_ows3.solar_absorp = 0.6 material_ows3.ir_emissivity = 0.9 out_wall_west = OuterWall(parent=tz) out_wall_west.name = "OuterWallWest" out_wall_west.area = 6 * 2.7 out_wall_west.orientation = 270.0 out_wall_west.tilt = 90.0 out_wall_west.inner_convection = 3.16 out_wall_west.outer_convection = 24.67 out_wall_west.inner_radiation = 5.13 out_wall_west.outer_radiation = 4.63 layer_oww1 = Layer(parent=out_wall_west, id=0) layer_oww1.thickness = 0.1 material_oww1 = Material(layer_oww1) material_oww1.name = "Concrete" material_oww1.density = 1400.0 material_oww1.heat_capac = 1000.0 / 1000 material_oww1.thermal_conduc = 0.51 material_oww1.ir_emissivity = 0.9 layer_oww2 = Layer(parent=out_wall_west, id=1) layer_oww2.thickness = 0.062 material_oww2 = Material(layer_oww2) material_oww2.name = "FoamInsulation" material_oww2.density = 10 material_oww2.heat_capac = 1400 / 1000 material_oww2.thermal_conduc = 0.04 layer_oww3 = Layer(parent=out_wall_west, id=2) layer_oww3.thickness = 0.009 material_oww3 = Material(layer_oww3) material_oww3.name = "WoodSiding" material_oww3.density = 530 material_oww3.heat_capac = 900 / 1000 material_oww3.thermal_conduc = 0.14 material_oww3.solar_absorp = 0.6 material_oww3.ir_emissivity = 0.9 in_wall_floor = Floor(parent=tz) in_wall_floor.name = "InnerWallFloor" in_wall_floor.area = 6 * 8 in_wall_floor.orientation = -2.0 in_wall_floor.tilt = 0.0 in_wall_floor.inner_convection = 4.13 in_wall_floor.inner_radiation = 5.13 layer_iwf1 = Layer(parent=in_wall_floor, id=0) layer_iwf1.thickness = 0.025 material_iwf1 = Material(layer_iwf1) material_iwf1.name = "Concrete" material_iwf1.density = 1400 material_iwf1.heat_capac = 1000 / 1000 material_iwf1.thermal_conduc = 1.13 material_iwf1.ir_emissivity = 0.9 layer_iwf2 = Layer(parent=in_wall_floor, id=1) layer_iwf2.thickness = 1.007 material_iwf2 = Material(layer_iwf2) material_iwf2.name = "Insulation" material_iwf2.density = 0.000000000001 # 0.0001, as small as possible material_iwf2.heat_capac = 0.000000000001 # 0.0001, as small as possible material_iwf2.thermal_conduc = 0.04 win_1 = Window(parent=tz) win_1.name = "WindowSouthLeft" win_1.area = 3 * 2 win_1.tilt = 90.0 win_1.orientation = 180.0 win_1.inner_convection = 3.16 win_1.inner_radiation = 5.13 win_1.outer_convection = 16.37 win_1.outer_radiation = 4.63 win_1.g_value = 0.789 win_1.a_conv = 0.03 # for the given U-value extracted from VDI 6007-2/-3 win_1_layer = Layer(parent=win_1) win_1_layer.id = 1 win_1_layer.thickness = 0.024 win_1_material = Material(win_1_layer) win_1_material.name = "GlasWindow" win_1_material.thermal_conduc = 0.15 win_1_material.transmittance = 0.907 win_1_material.ir_emissivity = 0.9 win_2 = Window(parent=tz) win_2.name = "WindowSouthRight" win_2.area = 3 * 2 win_2.tilt = 90.0 win_2.orientation = 180.0 win_2.inner_convection = 3.16 win_2.inner_radiation = 5.13 win_2.outer_convection = 16.37 win_2.outer_radiation = 4.63 win_2.g_value = 0.789 win_2.a_conv = 0.03 # for the given U-value extracted from VDI 6007-2/-3 win_2_layer = Layer(parent=win_2) win_2_layer.id = 1 win_2_layer.thickness = 0.024 win_2_material = Material(win_2_layer) win_2_material.name = "GlasWindow" win_2_material.thermal_conduc = 0.15 win_2_material.transmittance = 0.907 win_2_material.ir_emissivity = 0.9 # This is a dummy ground floor to export three and four elements models. # Please set values for floor plate in three element and four element # models to default. if number_of_elements >= 3: out_wall_gf = GroundFloor(parent=tz) out_wall_gf.name = "ExtWallGroundFloor" out_wall_gf.area = 6 * 8 out_wall_gf.orientation = -2.0 out_wall_gf.tilt = 0.0 out_wall_gf.inner_convection = 4.13 out_wall_gf.inner_radiation = 5.13 layer_ofgw1 = Layer(parent=out_wall_gf, id=0) layer_ofgw1.thickness = 1.003 material_ofgw1 = Material(layer_ofgw1) material_ofgw1.name = "Insulation" material_ofgw1.density = 0.0001 # as small as possible material_ofgw1.heat_capac = 0.0001 # as small as possible material_ofgw1.thermal_conduc = 0.04 if save: prj.save_project(file_name='ASHRAE140_900', path=path) return prj