def test_renewable(): starttime = time.time() # get raw building data set buildingSet = pd.read_csv(os.path.join(tsib.data.PATH, "episcope", "tabula_DE_wPersons.csv"), header=0, index_col=0) # get a random building ID ix = 24 ID = buildingSet.index[ix] # get time series data try_data, loc = tsib.readTRY(try_num=4) # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "ID": ID, "weatherData": try_data, "weatherID": "TRY_4", "roofOrientation": 0.0, "longitude": loc["longitude"], "latitude": loc["latitude"], }) # setup a building with the configuration bdgObj = tsib.Building(configurator=bdgcfg) # get the renewable profiles to manipulate them bdgObj.getRenewables()
def test_scaleHeatDemand(): # get raw building data set buildingSet = pd.read_csv(os.path.join(tsib.data.PATH, "episcope", "tabula_DE_wPersons.csv"), header=0, index_col=0) # get a random building ID ix = 24 ID = buildingSet.index[ix] # get time series data try_data, loc = tsib.readTRY(try_num=4) # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "ID": ID, "weatherData": try_data, "weatherID": "TRY_4", }) bdgObj = tsib.Building(configurator=bdgcfg) # get the design heat load origDesignLoad = bdgObj.thermalmodel.calcDesignHeatLoad() # scale to a reduced value bdgObj.thermalmodel.scaleHeatLoad(scale=0.5) # get updated load reducedDesignLoad = bdgObj.thermalmodel.calcDesignHeatLoad() np.testing.assert_almost_equal(reducedDesignLoad / 0.5, origDesignLoad, decimal=2)
def __init__( self, configurator=None, ): """ A building model which uses the IWU-Buildingtopology for parameterizing the physical building of a model. This can then be used to first run an occupancy simulation based on the CREST model (tsorb) and then a thermal simulation based on a 5R1C model to predict the heat loads. Parameters ---------- configurator: tsib.BuildingConfiguration, optional (default: None) Configuration dictionary which includes all parameters required for parameterizing a building. """ if configurator is None: self.configurator = tsib.BuildingConfiguration({}) else: if isinstance(configurator, tsib.BuildingConfiguration): self.configurator = configurator else: raise ValueError( "'configurator' needs to be of type " + '"buildingconfig.BuildingConfiguration"' ) self.cfg = self.configurator.getBdgCfg(includeSupply=True) self.IDentries = self.configurator.IDentries self.thermalmodel = tsib.Building5R1C(self.cfg) # status if the profiles have already been initialized self._has_occupancy_profiles = False self._occupancy_profile_names = [] self._has_heat_profiles = False self._heat_profile_names = [] self._has_renewable_potential_profiles = False self._renewable_profile_names = [] # define identifier for results self._ID = None # initialize time series for the building with relevant weather data self.timeseries = self.cfg['weather'][[key for key in self.cfg['weatherUnits']]] # initialize a dictionary to save the units self.units = self.cfg["weatherUnits"] return
def test_configuration_2(): # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "buildingYear": 1980, "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 2, "a_ref": 300., "surrounding": "Detached", "latitude": 52., "longitude": 13., }) test = bdgcfg.getBdgCfg() return
def test_configuration_1(): # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "refurbishment": False, "nightReduction": False, "occControl": False, "capControl": True, "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 1, "latitude": 49., "longitude": 12., }) test = bdgcfg.getBdgCfg() return
def test_configuration_other_countries(): # parameterize a building bdgcfg = tsib.BuildingConfiguration( { "buildingYear": 1980, "country": "BE", "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 1, "surrounding": "Detached", "latitude": 52., "longitude": 13., } ) test = bdgcfg.getBdgCfg() assert round(test["q_h_nd"]) == 185.
def test_surround_weather_error_with_dummy(): # parameterize a building bdgcfg = tsib.BuildingConfiguration( { "buildingYear": 1980, "country": "BE", "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 1, "weatherData": pd.DataFrame([[0,0,0,]], columns=["DHI", "T", "DNI"]), "weatherID": "Dummy", "surrounding": "Detached", "latitude": 50., "longitude": 1., } ) bdg = tsib.Building(configurator=bdgcfg) return
def test_get_ID(): # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "refurbishment": False, "nightReduction": False, "occControl": False, "capControl": True, "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 1, "latitude": 49., "longitude": 12., }) bdgObj = tsib.Building(configurator=bdgcfg) print('ID is : ' + str(bdgObj.ID)) return
def test_set_ID(): # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "buildingYear": 1980, "n_persons": 2, "roofOrientation": 0.0, "n_apartments": 2, "a_ref": 300., "surrounding": "Detached", "latitude": 52., "longitude": 13., }) bdgObj = tsib.Building(configurator=bdgcfg) bdgObj.ID = 'custom' if not bdgObj.ID == 'custom': raise ValueError() return
def test_smoke(): # Read buildings from episcope database bdgs_df = pd.read_csv(os.path.join("tsib/data/episcope/episcope.csv"), index_col=1) # Select random building by building code bdg_dict = bdgs_df.loc['DE.N.SFH.10.Gen.ReEx.001.001'].to_dict() # Create building configuration object # NOTE: The right kwargs have to be created bdg_cfg = tsib.BuildingConfiguration(bdg_dict) # Get weather data try_data, loc = tsib.readTRY() # Initialize a building object with this configuration for given weather # NOTE: Weather data seperated from building configuration bdg_obj = tsib.Building(configurator=bdg_cfg, weather=try_data) # Calculate loads bdg_obj.getLoad()
def test_configuration_3(): # parameterize a building kwgs = { "buildingYear": 1990, "latitude": 52.0, "longitude": 13.0, "comfortT_lb": 21., "comfortT_ub": 24., "WACC": 0.03, "roofTilt": 45.0, "surrounding": "Semi", "n_apartments": 2, "a_ref_app": 100., "n_persons": 2, "roofOrientation": 135.0, "costdata": "default_2016", "capControl": True, } bdgcfg = tsib.BuildingConfiguration(kwgs) test = bdgcfg.getBdgCfg() return
# %% import numpy as np # %% EXPORT_PATH = os.path.join('plots') # %% [markdown] # ### Define the building # %% [markdown] # Init building # %% bdgcfg = tsib.BuildingConfiguration({ 'refurbishment': False, 'nightReduction': True, 'buildingYear': 2005, 'occControl': False, 'capControl': True,'n_persons': 2, 'comfortT_lb': 20.0, 'comfortT_ub': 26.0, 'roofOrientation': 0.0, 'longitude': 7., 'latitude': 54. }) # %% bdgObj = tsib.Building(configurator = bdgcfg) # %% [markdown] # ## Get the load # %% bdgObj.get_load() # %% [markdown] # Plot # %%
def test_heatload(): starttime = time.time() # get raw building data set buildingSet = pd.read_csv(os.path.join(tsib.data.PATH, "episcope", "tabula_DE_wPersons.csv"), header=0, index_col=0) # get a random building ID ix = 24 ID = buildingSet.index[ix] # get time series data try_data, loc = tsib.readTRY(try_num=4) # parameterize a building bdgcfg = tsib.BuildingConfiguration({ "ID": ID, "weatherData": try_data, "weatherID": "TRY_4", "refurbishment": False, "nightReduction": False, "occControl": False, "capControl": True, "n_persons": 2, "comfortT_lb": 20.0, "comfortT_ub": 26.0, "roofOrientation": 0.0, "n_apartments": 1, "longitude": loc["longitude"], "latitude": loc["latitude"], }) # setup a building with the configuration bdgObj = tsib.Building(configurator=bdgcfg) # get the occupancy profiles to manipulate them bdgObj._get_occupancy_profile(bdgObj.cfg) # manipulate internal gains with tabula mean value bdgObj.cfg["Q_ig"] = (bdgObj.cfg["Q_ig"] * 15.552 / (bdgObj.cfg["Q_ig"].sum() / bdgObj.cfg["A_ref"])) # run simulation bdgObj.getHeatLoad() # take solver from environment variable # get specific heat demand q_sim = bdgObj.timeseries["Heating Load"].sum() / bdgObj.cfg["A_ref"] # get calculated heat demand by IWU q_iwu = buildingSet.loc[ID, "q_h_nd"] print("Profile generation took " + str(time.time() - starttime)) print("Spec. heat demand IWU [kWh/m²/a]: " + str(round(q_iwu))) print("Spec. heat demand 5R1C [kWh/m²/a]: " + str(round(q_sim))) if abs(q_sim - q_iwu) > 20: raise ValueError( "The difference between simulation and the values listed by the IWU is too high." ) if ix == 24: if not round(q_sim) == 197.0: raise ValueError( "Different result for mean heat load than expected.") return
cbar.set_label(label) # %% [markdown] # ### Define the building # %% [markdown] # Get a building configuration # %% cfg = tsib.BuildingConfiguration({ "country": 'DE', "buildingYear": 1990, "latitude": 50.0, "longitude": 8.0, "n_persons": 2, "a_ref": 150., "n_apartments": 1, "surrounding": "Detached", "mean_load": True, "occControl": False, }) # %% [markdown] # Parameterize the building model itself with the configuration # %% bdg = tsib.Building(configurator=cfg) # %% [markdown] # ### 2. Show the weather data as basis
# %% bdgs_raw # %% bdgs_dict = bdgs_raw.T.to_dict() # %% [markdown] # ### Loop over the buildings, define them and get their profile # %% bdg_cfgs = {} bdg_cfgs_print = {} # %% for bdg_ix in bdgs_dict: bdg_cfgs[bdg_ix] = tsib.BuildingConfiguration(bdgs_dict[bdg_ix]) bdg_cfgs_print[bdg_ix] = bdg_cfgs[bdg_ix].getBdgCfg() # %% bdg_cfgs_print[0] # %% import tsib # %% bdgs = {} # %% for bdg_ix in bdgs_dict: bdgs[bdg_ix] = tsib.Building(configurator=bdg_cfgs[bdg_ix]) bdgs[bdg_ix].getLoad()