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 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_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()
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 # %% bdgObj.detailed_results['Heating Load'].plot() # %% bdgObj.detailed_results['Heating Load']['20100101':'20100107'].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
"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 # %% [markdown] # Get current time series data. Until here, only weather data is provided. # %% bdg.timeseries.head() # %% [markdown] # Plot the weather data # %% for name in bdg.timeseries:
# %% 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() # %% [markdown] # ### Plot example results and export to CSV # %% bdgs[0].timeseries['Heating Load'].plot() # %% bdgs[0].timeseries['Electricity Load'].plot() # %% bdgs[0].toCSV(filename="example_result")