Esempio n. 1
0
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)
Esempio n. 2
0
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()
Esempio n. 3
0
def test_heatpump_cop():

    # get weather data
    try_data, loc = tsib.readTRY()

    # get cop profile
    CoP = tsib.simHeatpump(try_data["T"], COP_limit=6.)

    assert CoP.max() <= 6.0
    assert CoP.min() >= 0.0
Esempio n. 4
0
def test_pvlib():

    starttime = time.time()

    # Run PV simulation with Pv_lib from Sandia (default values)
    try_data, loc = tsib.readTRY()
    tmy_data = tsib.TRY2TMY(try_data)

    specific_load, space_coverage = tsib.simPhotovoltaic(tmy_data)

    print("Summary of specific load profile [kW/kWp]:")
    print(specific_load.describe())
    print("Space coverage [m^2/kWp]: " + str(space_coverage))
    print("Profile generation took " + str(time.time() - starttime) + "s")
Esempio n. 5
0
def test_solarthermal():
    # read weather data
    try_data, loc = tsib.readTRY(try_num=4)

    # format to tmy format
    tmy_data = tsib.TRY2TMY(try_data)

    # get solar thermal potential
    spec_load_st = sol.simSolarThermal(
        tmy_data,
        latitude=loc['latitude'],
        longitude=loc['longitude'],
        surface_tilt=30,
        surface_azimuth=180,
    )

    # expected yield in kWh/sqm/a
    np.testing.assert_array_almost_equal(spec_load_st.sum(),
                                         584.956523695128,
                                         decimal=0)
Esempio n. 6
0
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()
Esempio n. 7
0
def test_fireplace():

    # get weather data
    try_data, loc = tsib.readTRY()
    
    n_occs = 3
    occupancy_data = tsib.simSingleHousehold(n_occs, 2010, get_hot_water=True, resample_mean=True)

    # test for different seeds
    fullloadhours = 450

    # test for different seeds
    for seed in range(5):
        fireplaceprofile = tsib.simFireplace(
            try_data["T"],
            occupancy_data["OccActive"] / n_occs,
            n_ovens=1,
            T_oven_on=5,
            t_cool=5.0,
            fullloadSteps=fullloadhours,
            seed=seed,
        )
        assert fireplaceprofile.sum() < fullloadhours + 100
        assert fireplaceprofile.sum() > fullloadhours - 100
Esempio n. 8
0
import tsib

# %%
import multiprocessing as mp

# %% [markdown]
# Number of household size

# %%
HH_SIZE = [1, 2, 3, 4, 5]

# %% [markdown]
# Get time series for Potsdam

# %%
weather, loc = tsib.readTRY(try_num=4)

# %% [markdown]
# Get a time dataframe for performance checking

# %%
timeFrame = pd.DataFrame(0,
                         columns=['Start time', 'End time', 'Duration [s]'],
                         index=HH_SIZE)

# %% [markdown]
# Generate for all seeds the profiles, if not existant

# %%
SEEDS = [x for x in range(tsib.buildingmodel.TOTAL_PROFILE_NUM + 1)]
Esempio n. 9
0
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
Esempio n. 10
0
# %% [markdown]
# # Test weather data and pvlib

# %%

import matplotlib.pyplot as plt
# %matplotlib inline
# %load_ext autoreload
# %autoreload 2
import tsib

# %% [markdown]
# ## 1. Simulate PV with TRY data

# %%
try_data, loc = tsib.readTRY(5)

# %%
tmy_data = tsib.TRY2TMY(try_data)

# %%
pv_try, space_cov = tsib.simPhotovoltaic(tmy_data,
                                         latitude=loc['latitude'],
                                         longitude=loc['longitude'],
                                         losses=0.1,
                                         integrateInverter=True)

# %%
pv_try.sum()

# %%