diff --git a/docs/source/examples/cooking_app/cooking_app.rst b/docs/source/examples/cooking_app/cooking_app.rst index 1ccd5c6d..670a09c1 100644 --- a/docs/source/examples/cooking_app/cooking_app.rst +++ b/docs/source/examples/cooking_app/cooking_app.rst @@ -4,19 +4,19 @@ Cooking Appliances In this example, appliances with multiple preferences index and attributes are modelled. -To have a better understanding of RAMP features for modelling these +To have a better understanding of RAMP features for modelling this category of appliances, two households are considered: -1. A household with a fixed lunch habit of eating soup everyday. +1. A household with a fixed lunch habit of eating soup every day. 2. A household with two lunch preferences: cooking soup or rice. -The number of user preferences can be specified through the +The number of user preferences can be specified through **“user_preference”** parameter when initializing a **User** instance. .. code:: ipython3 # importing functions - from ramp import User,UseCase,calc_peak_time_range,yearly_pattern + from ramp import User, UseCase, get_day_type import pandas as pd Creating a user category @@ -25,21 +25,21 @@ Creating a user category .. code:: ipython3 user_1 = User( - user_name = "Household with a single lunch habit", - num_users = 1, - user_preference = 1, # user_1 has only one lunch preference + user_name="Household with single lunch habit", + num_users=1, + user_preference=1, # user_1 has only one lunch preference ) user_2 = User( - user_name = "Household with different lunch habit", - num_users = 1, - user_preference = 2, # user_2 has two lunch preferences + user_name="Household with different lunch habits", + num_users=1, + user_preference=2, # user_2 has two lunch preferences ) Defining the cycles for cooking soup and rice ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -For cooking soup, we assume the user needs 25 minutes divided +For cooking soup it is assumed that the user needs 25 minutes divided into two parts: ============= ===== ==== @@ -49,7 +49,7 @@ Boiling Water 1200 5 Cooking soup 750 20 ============= ===== ==== -For cooking rice, we assume the user needs 15 minutes divided +For cooking rice it is assumed that the user needs 15 minutes divided into two parts: ============= ===== ==== @@ -63,77 +63,75 @@ Cooking rice 600 10 # soup for lunch soup_1 = user_1.add_appliance( - name = "soup for lunch", - power = 1200, - func_time = 25, - func_cycle = 25, - thermal_p_var = 0.2, - fixed_cycle = 1, - window_1 = [12*60,15*60], - p_11 = 1200, # power of the first cycle - t_11 = 5, # time needed for the first cycle - p_12 = 750, # power of the second cycle - t_12 = 20, # time needed for the second cycle - cw11 = [12*60,15*60] + name="soup for lunch", + power=1200, + func_time=25, + func_cycle=25, + thermal_p_var=0.2, + fixed_cycle=1, + window_1=[12 * 60, 15 * 60], + p_11=1200, # power of the first cycle + t_11=5, # time needed for the first cycle + p_12=750, # power of the second cycle + t_12=20, # time needed for the second cycle + cw11=[12 * 60, 15 * 60], ) +The second user has two different preferences for lunch. Accordingly, we +need to model these preferences and their characteristics as two +different appliances. -The second user has two different preferences for lunch. Accordingly, we need to model -these preferences and their characterisitics as two different appliances. - -Each preference needs to be specified with its associated cooking energy needs, such as -the power, functioning time and the duty cycles of the cooking process. +Each preference needs to be specified with its associated cooking energy +needs, such as the power, functioning time and the duty cycles of the +cooking process. More importantly, for each preference, the user needs to specify the -index of preference by using the **pref_index** parameter. In this example, -soup is the first preference of the user (pref_index = 1), and rice is -the second one (pref_index = 2). +index of preference by using the **pref_index** parameter. In this +example, soup is the first preference of the user (pref_index = 1), and +rice is the second one (pref_index = 2). .. code:: ipython3 # soup for lunch soup_2 = user_2.add_appliance( - name = "soup for lunch", - power = 1200, - func_time = 25, - func_cycle = 25, - thermal_p_var = 0.2, - fixed_cycle = 1, - pref_index = 1, # the first preference - window_1 = [12*60,15*60], - p_11 = 1200, # power of the first cycle - t_11 = 5, # time needed for the first cycle - p_12 = 750, # power of the second cycle - t_12 = 20, # time needed for the second cycle - cw11 = [12*60,15*60] + name="soup for lunch", + power=1200, + func_time=25, + func_cycle=25, + thermal_p_var=0.2, + fixed_cycle=1, + pref_index=1, # the first preference + window_1=[12 * 60, 15 * 60], + p_11=1200, # power of the first cycle + t_11=5, # time needed for the first cycle + p_12=750, # power of the second cycle + t_12=20, # time needed for the second cycle + cw11=[12 * 60, 15 * 60], ) - - .. code:: ipython3 # rice for lunch rice_2 = user_2.add_appliance( - name = "rice for lunch", - power = 1200, - func_time = 15, - func_cycle = 15, - thermal_p_var = 0.2, - pref_index = 2, # the second preference - fixed_cycle = 1, - window_1 = [12*60,15*60], - p_11 = 1200, # power of the first cycle - t_11 = 5, # time needed for the first cycle - p_12 = 600, # power of the second cycle - t_12 = 10, # time needed for the second cycle - cw11 = [12*60,15*60] - + name="rice for lunch", + power=1200, + func_time=15, + func_cycle=15, + thermal_p_var=0.2, + pref_index=2, # the second preference + fixed_cycle=1, + window_1=[12 * 60, 15 * 60], + p_11=1200, # power of the first cycle + t_11=5, # time needed for the first cycle + p_12=600, # power of the second cycle + t_12=10, # time needed for the second cycle + cw11=[12 * 60, 15 * 60], ) .. code:: ipython3 - # you can have an overview of the just defined input data by using User.export_to_dataframe method - user_lunch = UseCase(users=[user_1,user_2]) + # you can have an overview of data inputs by usering User.export_to_dataframe method + user_lunch = UseCase(users=[user_1, user_2], date_start="2020-01-01") user_lunch.export_to_dataframe().T @@ -167,7 +165,7 @@ the second one (pref_index = 2). user_name - Household with a single lunch habit + Household with single lunch habit Household with different lunch habit Household with different lunch habit @@ -480,58 +478,58 @@ the second one (pref_index = 2). Generating a profile for some months ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. code:: ipython3 - - peak_time_range = calc_peak_time_range( - user_list = user_lunch.users - ) - year_behaviour = yearly_pattern() - - .. code:: ipython3 # number of days n_days = 90 + user_lunch.initialize(num_days=n_days) # storing all the profiles for all the users - profiles = pd.DataFrame(index = pd.date_range(start = "2020-01-01",periods = 1440*n_days,freq="T")) + profiles = pd.DataFrame( + index=pd.date_range(start="2020-01-01", periods=1440 * n_days, freq="T") + ) + + # here we need to use the for user in user_lunch.users: - # storing daily profiles for a user user_profiles = [] - for day in range(n_days): + for day_idx, day in enumerate(user_lunch.days): single_profile = user.generate_single_load_profile( - prof_i = day, # the day to generate the profile - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour + prof_i=day_idx, # the day to generate the profile + day_type=get_day_type(day), ) user_profiles.extend(single_profile) - + profiles[user.user_name] = user_profiles - - -Considering that the second user has the possibility of cooking rice for lunch, which -has a less energy-intensive cooking cycle, we expect to see a higher energy -consumption for the the user that only eats soup, in most of the cases. +.. parsed-literal:: + + You will simulate 90 day(s) from 2020-01-01 00:00:00 until 2020-03-31 00:00:00 + + +Considering that the second user has the possibility of cooking rice for +lunch, which has a less energy-intensive cooking cycle, we expect to see +a higher energy consumption for the user that only eats soup, in most of +the cases. .. code:: ipython3 # daily energy consumption - profiles.resample("1d").sum().plot(title = "daily energy consumption") + profiles.resample("1d").sum().plot(title="daily energy consumption") .. parsed-literal:: - + + +.. image:: output_13_1.png -.. image:: output_14_1.png diff --git a/docs/source/examples/fixed_flat_app/fixed_flat_app.rst b/docs/source/examples/fixed_flat_app/fixed_flat_app.rst index 1d624308..12f01860 100644 --- a/docs/source/examples/fixed_flat_app/fixed_flat_app.rst +++ b/docs/source/examples/fixed_flat_app/fixed_flat_app.rst @@ -4,7 +4,7 @@ Fixed-Flat Appliance .. code:: ipython3 # importing functions - from ramp import User,calc_peak_time_range,yearly_pattern + from ramp import User, UseCase, get_day_type import pandas as pd Creating a user @@ -12,10 +12,7 @@ Creating a user .. code:: ipython3 - school = User( - user_name = "School", - num_users = 1 - ) + school = User(user_name="School", num_users=1) Adding an appliance with flat and fixed consumption ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -23,62 +20,63 @@ Adding an appliance with flat and fixed consumption .. code:: ipython3 indoor_bulb = school.add_appliance( - name = "Indoor Light Bulb", - number = 10, - power = 25, - num_windows = 1, - func_time = 210, - time_fraction_random_variability = 0.2, - func_cycle = 60, - fixed = "yes", - flat = "yes", - + name="Indoor Light Bulb", + number=10, + power=25, + num_windows=1, + func_time=210, + time_fraction_random_variability=0.2, + func_cycle=60, + fixed="yes", # This means all the 'n' appliances of this kind are always switched-on together + flat="yes", # This means the appliance is not subject to random variability in terms of total usage time ) indoor_bulb.windows( - window_1 = [1200,1440], # from 20:00 to 24:00 - window_2 = [0,0], - random_var_w = 0.35, + window_1=[1200, 1440], # from 20:00 to 24:00 + window_2=[0, 0], + random_var_w=0.35, ) -Defining the peak time range using the calc_peak_time_range -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Initialize the usecase (it defines the peak time range and simulation time) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = [school] - ) + school_case = UseCase(users=[school], date_start="2023-01-01") + school_case.initialize(num_days=7) -Defining the yearly patterns -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By default the :code:`yearly_pattern` function returns weekdays (defined by 0) -/weekends (defined by 1) division +.. parsed-literal:: -.. code:: ipython3 + You will simulate 7 day(s) from 2023-01-01 00:00:00 until 2023-01-08 00:00:00 - year_behaviour = yearly_pattern() Generating a profile for the 1st week of the year ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +From the usecase directly + +.. code:: ipython3 + + first_week = school_case.generate_daily_load_profiles(flat=True) + +or from the user + .. code:: ipython3 first_week = [] - for i in range(7): + for day_idx, day in enumerate(school_case.days): first_week.extend( school.generate_single_load_profile( - prof_i = i, # the day to generate the profile - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour + prof_i=day_idx, # the day to generate the profile + peak_time_range=school_case.peak_time_range, + day_type=get_day_type(day), ) ) - .. code:: ipython3 - first_week = pd.DataFrame(first_week,columns=["household"]) + first_week = pd.DataFrame(first_week, columns=["household"]) first_week.plot() @@ -86,10 +84,11 @@ Generating a profile for the 1st week of the year .. parsed-literal:: - + .. image:: output_12_1.png + diff --git a/docs/source/examples/fixed_flat_app/output_12_1.png b/docs/source/examples/fixed_flat_app/output_12_1.png index 7b52a6d4..3c0fe8a9 100644 Binary files a/docs/source/examples/fixed_flat_app/output_12_1.png and b/docs/source/examples/fixed_flat_app/output_12_1.png differ diff --git a/docs/source/examples/multi_cycle/multi_cycle.rst b/docs/source/examples/multi_cycle/multi_cycle.rst index 4e8d42d8..f03e52e0 100644 --- a/docs/source/examples/multi_cycle/multi_cycle.rst +++ b/docs/source/examples/multi_cycle/multi_cycle.rst @@ -2,13 +2,13 @@ Appliances with multiple cycles =============================== An example of an appliance with multiple cycle is a fridge. Fridges -usually have different duty cycles, which can be estimated based on seasonal -temperature trends and/or frequency of user interaction (e.g., how often the -door gets opened). +usually have different duty cycles, which can be estimated based on +seasonal temperature trends and/or frequency of user interaction (e.g., +how often the door gets opened). In this example a fridge with 3 different duty cycles is modelled. The -time windows are defined for 3 different cycles across 3 different season -types: +time windows are defined for 3 different cycles across 3 different +season types: +--------+------------------------------+--------------+--------------+ | season | Standard cycle | Intermediate | Intensive | @@ -30,7 +30,7 @@ Creating the user and appliance .. code:: ipython3 # importing functions - from ramp import User,calc_peak_time_range,yearly_pattern + from ramp import User, UseCase, get_day_type import pandas as pd .. code:: ipython3 @@ -42,22 +42,21 @@ Creating the user and appliance # creating the appliance fridge = household.Appliance( - name = "Fridge", - number = 1, - power = 200, - num_windows = 1, - func_time = 1400, - time_fraction_random_variability = 0, - func_cycle = 30, - fixed = "yes", - fixed_cycle = 3, # number of cycles + name="Fridge", + number=1, + power=200, + num_windows=1, + func_time=1400, + time_fraction_random_variability=0, + func_cycle=30, + fixed="yes", + fixed_cycle=3, # number of cycles ) .. code:: ipython3 # setting the functioning windows - fridge.windows([0,1440]) # always on during the whole year - + fridge.windows([0, 1440]) # always on during the whole year Assigining the specific cycles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -67,26 +66,26 @@ Assigining the specific cycles # assiging the specific cycles # first cycle: standard cycle fridge.specific_cycle_1( - p_11 = 200, - t_11 = 20, - p_12 = 5, - t_12 = 10, + p_11=200, + t_11=20, + p_12=5, + t_12=10, ) # second cycle: intermediate cycle fridge.specific_cycle_2( - p_21 = 200, - t_21 = 15, - p_22 = 5, - t_22 = 15, + p_21=200, + t_21=15, + p_22=5, + t_22=15, ) # third cycle: intensive cycle fridge.specific_cycle_3( - p_31 = 200, - t_31 = 10, - p_32 = 5, - t_32 = 20, + p_31=200, + t_31=10, + p_32=5, + t_32=20, ) After defining the cycle power and duration parameters, the time windows @@ -96,10 +95,7 @@ of year at which the cycles happens should be specifid by: # defining cycle behaviour fridge.cycle_behaviour( - cw11 = [480,1200], - cw21 = [300,479], - cw31 = [0,229], - cw32 = [1201,1440] + cw11=[480, 1200], cw21=[300, 479], cw31=[0, 229], cw32=[1201, 1440] ) Buidling the profiles @@ -107,29 +103,27 @@ Buidling the profiles .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = [household] - ) - year_behaviour = yearly_pattern() + use_case = UseCase(users=[household]) + peak_time_range = use_case.calc_peak_time_range() .. code:: ipython3 # days to build the profiles - days = { - "May-16": 136, - "August-16": 228, - "December-16": 350, - } + days = [ + "2020-05-16", + "2020-08-16", + "2020-12-16", + ] - profiles = pd.DataFrame(index=range(0,1440),columns = days.keys()) + profiles = pd.DataFrame(index=range(0, 1440), columns=days) - for day,i in days.items(): + for day_idx, day in enumerate(days): profile = household.generate_single_load_profile( - prof_i = i, # the day to generate the profile - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour + prof_i=day_idx, # the day to generate the profile + peak_time_range=peak_time_range, + day_type=get_day_type(day), ) - + profiles[day] = profile .. code:: ipython3 @@ -139,18 +133,18 @@ Buidling the profiles .. parsed-literal:: - May-16 August-16 December-16 - 0 0.001 0.001 0.001 - 1 0.001 0.001 0.001 - 2 0.001 5.000 0.001 - 3 0.001 5.000 0.001 - 4 0.001 5.000 0.001 - ... ... ... ... - 1435 5.000 5.000 200.000 - 1436 5.000 200.000 200.000 - 1437 5.000 200.000 200.000 - 1438 5.000 200.000 200.000 - 1439 5.000 200.000 200.000 + 2020-05-16 2020-08-16 2020-12-16 + 0 0.001 5.000 0.001 + 1 0.001 5.000 0.001 + 2 0.001 5.000 0.001 + 3 5.000 5.000 0.001 + 4 5.000 5.000 0.001 + ... ... ... ... + 1435 0.001 0.001 0.001 + 1436 0.001 0.001 0.001 + 1437 0.001 0.001 0.001 + 1438 0.001 0.001 0.001 + 1439 0.001 0.001 0.001 [1440 rows x 3 columns] diff --git a/docs/source/examples/multi_cycle/output_15_1.png b/docs/source/examples/multi_cycle/output_15_1.png index 4d30f9af..e74e5e89 100644 Binary files a/docs/source/examples/multi_cycle/output_15_1.png and b/docs/source/examples/multi_cycle/output_15_1.png differ diff --git a/docs/source/examples/occasional_use/occasional_use.rst b/docs/source/examples/occasional_use/occasional_use.rst index fda03849..ad9be5a6 100644 --- a/docs/source/examples/occasional_use/occasional_use.rst +++ b/docs/source/examples/occasional_use/occasional_use.rst @@ -1,29 +1,29 @@ Appliances with occasional use ============================== -There are some appliances that are occasionally included in the mix pf -appliances that the user switches-on during the day. For example, an iron, -a stereo, printers, etc. +There are some appliances that are occasionally included in the mix of +appliances that the user switches on during the day. For example, an +iron, a stereo, printers, etc. Within RAMP, the user may specify the probability of using an appliance -on the daily mix with a parameter called, **occasional_use**. +on the daily mix with a parameter called **occasional_use**. -When :code:`occasional_use = 0`, the appliance is always present in the mix, and -when :code:`occasional_use = 1`, the appliance is never present. Any in-between -values will lead to a probablistic calculation to decide whether the appliance -is used or not on a given day. +When ``occasional_use = 0``, the appliance is always present in the mix, +and when ``occasional_use = 1``, the appliance is never present. Any +in-between values will lead to a probabilistic calculation to decide +whether the appliance is used or not on a given day. -The following example, investigates the effect of this parameter by -modelling two user category: \* A household that uses a computer with -ocationally \* A school that uses the computer everyday +The following example investigates the effect of this parameter by +modelling two user categories: \* A household that uses a computer +occasionally \* A school that uses the computer every day .. code:: ipython3 # importing functions - from ramp import User,calc_peak_time_range,yearly_pattern + from ramp import User, UseCase, get_day_type import pandas as pd -Creating a user category and appliances +Creating user categories and appliances ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: ipython3 @@ -34,38 +34,35 @@ Creating a user category and appliances .. code:: ipython3 computer_0 = household.add_appliance( - name = "Household Computer", - number = 1, - power = 50, - num_windows = 1, - func_time = 210, - occasional_use = 0.5, # 50% chance of occasional use, - window_1 = [510,750], + name="Household Computer", + number=1, + power=50, + num_windows=1, + func_time=210, + occasional_use=0.5, # 50% chance of occasional use, + window_1=[510, 750], ) - .. code:: ipython3 computer_1 = school.add_appliance( - name = "School Computer", - number = 1, - power = 50, - num_windows = 1, - func_time = 210, - time_fraction_random_variability = 0.2, - func_cycle = 10, - occasional_use = 1, # always present in the mix of appliances, - window_1 = [510,750], + name="School Computer", + number=1, + power=50, + num_windows=1, + func_time=210, + time_fraction_random_variability=0.2, + func_cycle=10, + occasional_use=1, # always present in the mix of appliances, + window_1=[510, 750], ) - - .. code:: ipython3 # Checking the maximum profile of the two appliances - max_profile_c1 = pd.DataFrame(computer_0.maximum_profile,columns=[computer_0.name]) - max_profile_c2 = pd.DataFrame(computer_1.maximum_profile,columns=[computer_1.name]) + max_profile_c1 = pd.DataFrame(computer_0.maximum_profile, columns=[computer_0.name]) + max_profile_c2 = pd.DataFrame(computer_1.maximum_profile, columns=[computer_1.name]) max_profile_c1.plot() max_profile_c2.plot() @@ -75,7 +72,7 @@ Creating a user category and appliances .. parsed-literal:: - + @@ -92,36 +89,31 @@ Generating profiles .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = [household,school] - ) - year_behaviour = yearly_pattern() + use_case = UseCase(users=[household, school]) + use_case.initialize(5) + + +.. parsed-literal:: + + You will simulate 5 day(s) from 2023-12-01 00:00:00 until 2023-12-06 00:00:00 + .. code:: ipython3 - # plotting profiles for 5 days - days = range(10) - - for day in days: + for day_idx, day in enumerate(use_case.days): household_profile = household.generate_single_load_profile( - prof_i = day, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour + prof_i=day_idx, day_type=get_day_type(day) ) - + school_profile = school.generate_single_load_profile( - prof_i = day, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour + prof_i=day_idx, day_type=get_day_type(day) ) - + pd.DataFrame( - data = [household_profile,school_profile], - columns = range(1440), - index = [household.user_name,school.user_name] + data=[household_profile, school_profile], + columns=range(1440), + index=[household.user_name, school.user_name], ).T.plot(title=f"day - {day}") - - @@ -144,26 +136,6 @@ Generating profiles .. image:: output_9_4.png - -.. image:: output_9_5.png - - - -.. image:: output_9_6.png - - - -.. image:: output_9_7.png - - - -.. image:: output_9_8.png - - - -.. image:: output_9_9.png - - As it can be seen from the figures, the computer is always present in -the school's appliance mix while, for the household, it is only occasionally -present. +the school’s appliance mix while, for the household, it is only +occasionally present. diff --git a/docs/source/examples/occasional_use/output_6_1.png b/docs/source/examples/occasional_use/output_6_1.png index c9f2fce9..00924f12 100644 Binary files a/docs/source/examples/occasional_use/output_6_1.png and b/docs/source/examples/occasional_use/output_6_1.png differ diff --git a/docs/source/examples/occasional_use/output_6_2.png b/docs/source/examples/occasional_use/output_6_2.png index 2a40a2ca..322044ae 100644 Binary files a/docs/source/examples/occasional_use/output_6_2.png and b/docs/source/examples/occasional_use/output_6_2.png differ diff --git a/docs/source/examples/occasional_use/output_9_0.png b/docs/source/examples/occasional_use/output_9_0.png index 8ac7d21f..32d15e93 100644 Binary files a/docs/source/examples/occasional_use/output_9_0.png and b/docs/source/examples/occasional_use/output_9_0.png differ diff --git a/docs/source/examples/occasional_use/output_9_1.png b/docs/source/examples/occasional_use/output_9_1.png index 64a16ded..4587091a 100644 Binary files a/docs/source/examples/occasional_use/output_9_1.png and b/docs/source/examples/occasional_use/output_9_1.png differ diff --git a/docs/source/examples/occasional_use/output_9_2.png b/docs/source/examples/occasional_use/output_9_2.png index c6251df7..4f3c7049 100644 Binary files a/docs/source/examples/occasional_use/output_9_2.png and b/docs/source/examples/occasional_use/output_9_2.png differ diff --git a/docs/source/examples/occasional_use/output_9_3.png b/docs/source/examples/occasional_use/output_9_3.png index 0ee1781c..940801e2 100644 Binary files a/docs/source/examples/occasional_use/output_9_3.png and b/docs/source/examples/occasional_use/output_9_3.png differ diff --git a/docs/source/examples/occasional_use/output_9_4.png b/docs/source/examples/occasional_use/output_9_4.png index a5074c36..1b03b3b5 100644 Binary files a/docs/source/examples/occasional_use/output_9_4.png and b/docs/source/examples/occasional_use/output_9_4.png differ diff --git a/docs/source/examples/parallel_processing/parallel_processing.rst b/docs/source/examples/parallel_processing/parallel_processing.rst index 22891b1c..43571111 100644 --- a/docs/source/examples/parallel_processing/parallel_processing.rst +++ b/docs/source/examples/parallel_processing/parallel_processing.rst @@ -1,138 +1,156 @@ Parallel processing =================== -There is possibility to generate usecases profiles at the appliance -level using parallel processing. +There is the possibility of generating UseCase profiles using parallel +processing. -For example to generate 365 profiles using a parallel process in shell -use the ``-p`` option +For example, to generate 365 profiles using a parallel process in shell, +use the ``-p`` option. -.. code:: shell - - ramp -i -p -n 365 +ramp -i -p -n 365 The following cells provide you with a way to use the parallel process -in a pure python code +in a pure python code. .. code:: ipython3 from ramp import UseCase import numpy as np - import random + import random import math import pandas as pd - from ramp.core.initialise import initialise_inputs from ramp.core.utils import calc_time_taken, get_day_type - from ramp.core.core import User, UseCase - from ramp.core.stochastic_process import calc_peak_time_range + from ramp import User, UseCase from ramp.post_process import post_process as pp - uc = UseCase() + use_case = UseCase(date_start="2022-01-01", date_end="2022-01-09", peak_enlarge=0.15) household = User( - user_name = "Household", - num_users = 10, + user_name="Household", + num_users=10, ) indoor_bulb = household.add_appliance( - name = "Indoor Light Bulb", - number = 6, - power = 7, - num_windows = 2, - func_time = 120, - time_fraction_random_variability = 0.2, - func_cycle = 10, - window_1 = [1170,1440], # from 19:30 to 24:00 - window_2 = [0,30], # from 24 to 00:30 - random_var_w = 0.35, + name="Indoor Light Bulb", + number=6, + power=7, + num_windows=2, + func_time=120, + time_fraction_random_variability=0.2, + func_cycle=10, + window_1=[1170, 1440], # from 19:30 to 24:00 + window_2=[0, 30], # from 24 to 00:30 + random_var_w=0.35, ) - uc.add_user(household) - - num_profiles = 1 - Profiles_list = [] - - days = pd.date_range(start="2022-01-01", end="2022-01-09") - - peak_enlarge = 0.15 - - # Calculation of the peak time range, which is used to discriminate between off-peak - # and on-peak coincident switch-on probability, corresponds to step 1. of [1], p.6 - peak_time_range = calc_peak_time_range(uc.users, peak_enlarge) - + use_case.add_user(household) + + +.. parsed-literal:: + You will simulate 9 day(s) from 2022-01-01 00:00:00 until 2022-01-10 00:00:00 -Run usecase without parallel processing + +Run UseCase without parallel processing --------------------------------------- .. code:: ipython3 - for day in days: - print("Day", day) + daily_profiles = use_case.generate_daily_load_profiles(flat=False, verbose=True) - # without // processing - daily_profiles = uc.generate_daily_load_profiles(num_profiles, peak_time_range, get_day_type(day)) + # Post-processes the results and generates plots + Profiles_avg, Profiles_list_kW, Profiles_series = pp.Profile_formatting(daily_profiles) + pp.Profile_series_plot(Profiles_series) # by default, profiles are plotted as a series - Profiles_list.append(np.mean(daily_profiles, axis=0)) + if ( + len(daily_profiles) > 1 + ): # if more than one daily profile is generated, also cloud plots are shown + pp.Profile_cloud_plot(daily_profiles, Profiles_avg) + + +.. parsed-literal:: + + Day 1 / 9 completed + Day 2 / 9 completed + Day 3 / 9 completed + Day 4 / 9 completed + Day 5 / 9 completed + Day 6 / 9 completed + Day 7 / 9 completed + Day 8 / 9 completed + Day 9 / 9 completed + + + +.. image:: output_6_1.png + + + +.. image:: output_6_2.png + + +Run UseCase with parallel processing +------------------------------------ + +Explicitly calling the parallel method + +.. code:: ipython3 + + Profiles_list = use_case.generate_daily_load_profiles_parallel(flat=False) # Post-processes the results and generates plots Profiles_avg, Profiles_list_kW, Profiles_series = pp.Profile_formatting(Profiles_list) pp.Profile_series_plot(Profiles_series) # by default, profiles are plotted as a series - if len(Profiles_list) > 1: # if more than one daily profile is generated, also cloud plots are shown + if ( + len(Profiles_list) > 1 + ): # if more than one daily profile is generated, also cloud plots are shown pp.Profile_cloud_plot(Profiles_list, Profiles_avg) .. parsed-literal:: - Day 2022-01-01 00:00:00 - Day 2022-01-02 00:00:00 - Day 2022-01-03 00:00:00 - Day 2022-01-04 00:00:00 - Day 2022-01-05 00:00:00 - Day 2022-01-06 00:00:00 - Day 2022-01-07 00:00:00 - Day 2022-01-08 00:00:00 - Day 2022-01-09 00:00:00 + Computing appliances profiles: 100%|████████| 90/90 [00:00<00:00, 1284.63unit/s] -.. image:: output_5_1.png +.. image:: output_8_1.png -.. image:: output_5_2.png +.. image:: output_8_2.png -Run usecase with parallel processing ------------------------------------- +You can also set the ``parallel_processing`` attribute of the +``UseCase`` instance to ``True`` and use the +``generate_daily_load_profiles`` .. code:: ipython3 + use_case.parallel_processing = True - day_types = [get_day_type(day) for day in days] - - Profiles_list = uc.generate_daily_load_profiles_parallel(len(days), peak_time_range, day_types) + Profiles_list = use_case.generate_daily_load_profiles(flat=False) # Post-processes the results and generates plots Profiles_avg, Profiles_list_kW, Profiles_series = pp.Profile_formatting(Profiles_list) pp.Profile_series_plot(Profiles_series) # by default, profiles are plotted as a series - if len(Profiles_list) > 1: # if more than one daily profile is generated, also cloud plots are shown + if ( + len(Profiles_list) > 1 + ): # if more than one daily profile is generated, also cloud plots are shown pp.Profile_cloud_plot(Profiles_list, Profiles_avg) - - .. parsed-literal:: - Computing appliances profiles: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 90/90 [00:00<00:00, 2093.11unit/s] + Computing appliances profiles: 100%|████████| 90/90 [00:00<00:00, 1437.07unit/s] + +.. image:: output_10_1.png -.. image:: output_7_1.png +.. image:: output_10_2.png -.. image:: output_7_2.png diff --git a/docs/source/examples/plot_class/output_38_1.png b/docs/source/examples/plot_class/output_38_1.png index 1b40f54d..bca73826 100644 Binary files a/docs/source/examples/plot_class/output_38_1.png and b/docs/source/examples/plot_class/output_38_1.png differ diff --git a/docs/source/examples/simple_bulb/output_6_1.png b/docs/source/examples/simple_bulb/output_6_1.png index 2a668d5b..01f75a33 100644 Binary files a/docs/source/examples/simple_bulb/output_6_1.png and b/docs/source/examples/simple_bulb/output_6_1.png differ diff --git a/docs/source/examples/simple_bulb/output_6_2.png b/docs/source/examples/simple_bulb/output_6_2.png index 45ce748c..0e38050b 100644 Binary files a/docs/source/examples/simple_bulb/output_6_2.png and b/docs/source/examples/simple_bulb/output_6_2.png differ diff --git a/docs/source/examples/simple_bulb/simple_bulb.rst b/docs/source/examples/simple_bulb/simple_bulb.rst index 4b6666da..fd4ed059 100644 --- a/docs/source/examples/simple_bulb/simple_bulb.rst +++ b/docs/source/examples/simple_bulb/simple_bulb.rst @@ -1,10 +1,10 @@ -Simple Appliances with multiple functioning time -================================================ +Simple Appliances with multiple functioning windows +=================================================== .. code:: ipython3 # importing functions - from ramp import User,calc_peak_time_range,yearly_pattern + from ramp import User, UseCase, get_day_type import pandas as pd Creating a user category @@ -13,8 +13,8 @@ Creating a user category .. code:: ipython3 household = User( - user_name = "Household", - num_users = 10, + user_name="Household", + num_users=10, ) Creating a simple appliance with two functioning time @@ -23,25 +23,24 @@ Creating a simple appliance with two functioning time .. code:: ipython3 indoor_bulb = household.add_appliance( - name = "Indoor Light Bulb", - number = 6, - power = 7, - num_windows = 2, - func_time = 120, - time_fraction_random_variability = 0.2, - func_cycle = 10, - window_1 = [1170,1440], # from 19:30 to 24:00 - window_2 = [0,30], # from 24 to 00:30 - random_var_w = 0.35, + name="Indoor Light Bulb", + number=6, + power=7, + num_windows=2, + func_time=120, + time_fraction_random_variability=0.2, + func_cycle=10, + window_1=[1170, 1440], # from 19:30 to 24:00 + window_2=[0, 30], # from 24 to 00:30 + random_var_w=0.35, ) - .. code:: ipython3 # Checking the maximum profile of the appliance and user - max_profile_bulb = pd.DataFrame(indoor_bulb.maximum_profile,columns=["appliance"]) - max_profile_user = pd.DataFrame(household.maximum_profile,columns=["household"]) + max_profile_bulb = pd.DataFrame(indoor_bulb.maximum_profile, columns=["appliance"]) + max_profile_user = pd.DataFrame(household.maximum_profile, columns=["household"]) max_profile_bulb.plot() max_profile_user.plot() @@ -51,7 +50,7 @@ Creating a simple appliance with two functioning time .. parsed-literal:: - + @@ -63,128 +62,81 @@ Creating a simple appliance with two functioning time .. image:: output_6_2.png -Defining the peak time range using the calc_peak_time_range -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Whole year profile functionality +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = [household] - ) - - print(peak_time_range) + whole_year_profile = [] + use_case = UseCase(users=[household], date_start="2020-01-01", date_end="2020-12-31") + whole_year_profile = use_case.generate_daily_load_profiles() .. parsed-literal:: - [1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 - 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 - 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 - 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 - 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 - 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 - 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 - 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 - 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 - 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 - 1362 1363 1364 1365 1366 1367 1368 1369] + You will simulate 366 day(s) from 2020-01-01 00:00:00 until 2021-01-01 00:00:00 -Defining the yearly patterns -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. code:: ipython3 -by default the yearly_pattern function returns weekdays (defined by 0) -/weekends (defined by 1) division + whole_year_profile = pd.DataFrame( + whole_year_profile, columns=["household"], index=use_case.datetimeindex + ) + whole_year_profile.plot() -.. code:: ipython3 - year_behaviour = yearly_pattern() - - print(year_behaviour) .. parsed-literal:: - [0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. - 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. - 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. - 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. - 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. - 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. - 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. - 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. - 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. - 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. - 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. - 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. - 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. - 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. - 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. 0. 0. 1. 1. 0. 0. 0. - 0. 0. 1. 1. 0.] - - -Generating a profile for the ith day of the year -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + -.. code:: ipython3 - single_profile = household.generate_single_load_profile( - prof_i = 1, # the day to generate the profile - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour - ) -.. code:: ipython3 +.. image:: output_9_1.png - single_profile = pd.DataFrame(single_profile,columns=["household"]) - single_profile.plot() +Generating a profile for a single day +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +provide day_type=0 for weekday and day_type=1 for weekends +.. code:: ipython3 + single_profile = household.generate_single_load_profile(day_type=0) -.. parsed-literal:: +.. code:: ipython3 - + single_profile = pd.DataFrame(single_profile, columns=["household"]) + single_profile.plot() -.. image:: output_13_1.png +.. parsed-literal:: + -Whole year profile functionality -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. code:: ipython3 - whole_year_profile = [] - - for i in range(365): - whole_year_profile.extend( - household.generate_single_load_profile( - prof_i = i, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour - - ) - ) -.. code:: ipython3 +.. image:: output_12_1.png + - ### Generating aggregated_load_profile for the user category +Generating aggregated_load_profile for the user category +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Single daily profiles are aggregated for all the users defined within +the User class .. code:: ipython3 - aggregated_profile = household.generate_aggregated_load_profile( - prof_i = 1, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour - ) + aggregated_profile = household.generate_aggregated_load_profile() .. code:: ipython3 - aggregated_profile = pd.DataFrame(aggregated_profile,columns = ["household"]) + aggregated_profile = pd.DataFrame(aggregated_profile, columns=["household"]) aggregated_profile.plot() @@ -192,10 +144,11 @@ Whole year profile functionality .. parsed-literal:: - + + +.. image:: output_15_1.png -.. image:: output_18_1.png diff --git a/docs/source/examples/thermal_app/output_15_1.png b/docs/source/examples/thermal_app/output_15_1.png index db617f0a..e8d7662b 100644 Binary files a/docs/source/examples/thermal_app/output_15_1.png and b/docs/source/examples/thermal_app/output_15_1.png differ diff --git a/docs/source/examples/thermal_app/output_6_1.png b/docs/source/examples/thermal_app/output_6_1.png index 848383be..f13e7b8e 100644 Binary files a/docs/source/examples/thermal_app/output_6_1.png and b/docs/source/examples/thermal_app/output_6_1.png differ diff --git a/docs/source/examples/thermal_app/thermal_app.rst b/docs/source/examples/thermal_app/thermal_app.rst index 84fca84a..de36db0d 100644 --- a/docs/source/examples/thermal_app/thermal_app.rst +++ b/docs/source/examples/thermal_app/thermal_app.rst @@ -3,13 +3,17 @@ Thermal loads This example input file represents a single household user whose only load is the “shower”. The example showcases how to model thermal loads -by means of the :code:`thermal_P_var` attribute. +by: 1) using a time-varying average ``power`` attribute, pre-calculated +as a function of the average daily groundwater temperature; and 2) using +the ``thermal_p_var`` attribute to add further variability to the actual +power absorbed by the appliance in each usage event, which reflects the +randomness of user behaviour in preferring a slightly warmer or colder +shower temperature. .. code:: ipython3 # importing functions - from ramp import User,calc_peak_time_range,yearly_pattern - from ramp import load_data + from ramp import User, UseCase, load_data, get_day_type import pandas as pd Creating a user category and appliances @@ -19,10 +23,11 @@ Creating a user category and appliances household = User() -When the power is varying during the day, the “power” parameter needs to -be passed as a pd.DataFrame or np.array with a daily profile (365 rows -of data). For this exercise, data can be loaded from the default -examples in ramp: +When the power varies across days of the year, for instance, as a +function of the average daily groundwater temperature, the “power” +parameter can be passed as a ``pd.DataFrame`` or ``np.array`` with a +daily profile (365 rows of data). For this exercise, data can be loaded +from the default examples in ramp: .. code:: ipython3 @@ -38,7 +43,7 @@ examples in ramp: .. parsed-literal:: - + @@ -49,68 +54,55 @@ examples in ramp: .. code:: ipython3 shower = household.add_appliance( - name = "Shower", - number = 1, - power = shower_power, - num_windows = 2, - func_time = 15, - time_fraction_random_variability = 0.1, - func_cycle = 3, - window_1 = [390,540], - window_2 = [1080,1200], - random_var_w = 0.2 + name="Shower", + number=1, + power=shower_power, + num_windows=2, + func_time=15, + time_fraction_random_variability=0.1, + func_cycle=3, + window_1=[390, 540], + window_2=[1080, 1200], + random_var_w=0.2, ) - -Generating profiles -~~~~~~~~~~~~~~~~~~~ +Generating profiles for increasing degrees of ``thermal_p_var`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = [household] - ) - year_behaviour = yearly_pattern() + usecase = UseCase(users=[household], date_start="2020-01-01") + usecase.initialize(num_days=365) -.. code:: ipython3 - # generating the yearly profiles for different thermal_P_var +.. parsed-literal:: + + You will simulate 365 day(s) from 2020-01-01 00:00:00 until 2020-12-31 00:00:00 + .. code:: ipython3 - def thermal_P_var_sensitivity(values): - + def thermal_p_var_sensitivity(values): # buidling a pd.DataFrame for saving sensitivity results - results = pd.DataFrame( - index = pd.date_range(start = "2020-01-01",periods = 1440*365,freq="T"), - columns = [f"P_var = {value}" for value in values] + results = pd.DataFrame( + index=pd.date_range(start="2020-01-01", periods=1440 * 365, freq="T"), + columns=[f"p_var = {value}" for value in values], ) - + for value in values: - # changing the thermal_P_var - household.thermal_P_var = value - - # creating a list to sotre profiles for all the years of the year - profiles = [] - for day in range(365): + shower.thermal_p_var = value + + profiles = usecase.generate_daily_load_profiles(flat=True) - profile = household.generate_single_load_profile( - prof_i = day, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour - ) + # assigning the yearly profile for a given sensitivity case + results[f"p_var = {value}"] = profiles - profiles.extend(profile) - - # assiging the yearly profile for a given sensitivity case - results[f"P_var = {value}"] = profiles - return results .. code:: ipython3 - sensitivity_results = thermal_P_var_sensitivity([0,0.25,0.5,0.75,1]) + sensitivity_results = thermal_p_var_sensitivity([0, 0.25, 0.5, 0.75, 1]) .. code:: ipython3 @@ -139,11 +131,11 @@ Generating profiles - P_var = 0 - P_var = 0.25 - P_var = 0.5 - P_var = 0.75 - P_var = 1 + p_var = 0 + p_var = 0.25 + p_var = 0.5 + p_var = 0.75 + p_var = 1 @@ -256,10 +248,31 @@ Generating profiles .. parsed-literal:: - + + + + + +.. image:: output_14_1.png + + +.. code:: ipython3 + + first_day = pd.date_range( + start="2020-01-01 00:00:00", freq="1min", periods=24 * 60 # a full day + ) + sensitivity_results.loc[first_day].plot() + + + + +.. parsed-literal:: + + .. image:: output_15_1.png + diff --git a/docs/source/examples/using_excel/output_17_1.png b/docs/source/examples/using_excel/output_17_1.png index 6f66029f..f518803b 100644 Binary files a/docs/source/examples/using_excel/output_17_1.png and b/docs/source/examples/using_excel/output_17_1.png differ diff --git a/docs/source/examples/using_excel/using_excel.rst b/docs/source/examples/using_excel/using_excel.rst index 25209c9b..a97dba6a 100644 --- a/docs/source/examples/using_excel/using_excel.rst +++ b/docs/source/examples/using_excel/using_excel.rst @@ -1,32 +1,31 @@ Using tabular inputs to build a model -============================ +===================================== -When the number of users or appliances is high, it can be difficult -to create a model using python scripts. Therefore, RAMP allows you -to create inputs in tabular format (.xlsx). In this example we show -a use case of this functionality. +When the number of users or appliances is high, it can be difficult to +create a model using Python scripts. Therefore, RAMP allows you to +create inputs in tabular format (``.xlsx``). On the other hand, it is +still possible to use Python to generate a large tabular file with +default parameter values, which can then be more easily customised. In +this example, we show a possible utilisation of this functionality. .. code:: ipython3 - from ramp import User, Appliance, UseCase - from ramp import calc_peak_time_range,yearly_pattern + from ramp import User, Appliance, UseCase, get_day_type import pandas as pd -At the first step, user needs to creat User classes and assign -Appliances to the user class without assiging any detailed appliance -characteristics +As a first step, one must create ``User`` classes and assign +``Appliances`` to the user class without assigning detailed appliance +characteristics. Hence, users and their appliances are added to a +``UseCase``. -Buidling a model database -~~~~~~~~~~~~~~~~~~~~~~~~~ +Building a tabular file populated with default data +--------------------------------------------------- .. code:: ipython3 # Defining a dict of users with their appliances - user_app = { - "household" : ["light","tv"], - "school": ["light","computer"] - } + user_app = {"household": ["light", "tv"], "school": ["light", "computer"]} .. code:: ipython3 @@ -36,26 +35,25 @@ Buidling a model database .. code:: ipython3 # assinging the appliances to users - for user,apps in user_app.items(): - - user_instance = User(user_name = user) - + for user, apps in user_app.items(): + user_instance = User(user_name=user) + for app in apps: app_instance = user_instance.add_appliance(name=app) app_instance.windows() - + use_case.add_user(user_instance) .. parsed-literal:: - UserWarning: No windows is declared, default window of 24 hours is selected - warnings.warn(UserWarning("No windows is declared, default window of 24 hours is selected")) + /home/fl/GitHub-repos/RAMP/ramp/core/core.py:1198: UserWarning: No windows is declared, default window of 24 hours is selected + warnings.warn( -Once the users and appliances are added to the :code:`use_case` instance, the -user can get a pd.DataFrame or an .xlsx file of all the data with the -default values. +Once the ``Users`` and ``Appliances`` are added to the ``use_case`` +instance, the model user can get a ``pd.DataFrame`` or an ``.xlsx`` file +of all the data with the default values. Exporting the database ~~~~~~~~~~~~~~~~~~~~~~ @@ -218,11 +216,12 @@ Exporting the database .. code:: ipython3 # Printing out the database to an .xlsx file - use_case.save("path/name_of_file") + use_case.save("example_excel_usecase") -Once the function is used, an .xlsx file will be created in the given -path. Now you can easily fill-out the information in the .xlsx file and -load the data into the model database as detailed below. +Once the function is used, an ``.xlsx`` file will be created in the +given path. Now, you can easily fill out the information in the +``.xlsx`` file and load the data into the model database as detailed +below. Loading the database ~~~~~~~~~~~~~~~~~~~~ @@ -231,54 +230,88 @@ Loading the database # loading data - use_case = UseCase() # creating a new UseCase instance - use_case.load("path/name_of_file.xlsx") + use_case = UseCase() # creating a new UseCase instance + use_case.load("example_excel_usecase_filled.xlsx") Generating load profiles -~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------ Once the database is loaded, the user can continue with the normal -analysis like generating aggregated profiles +analysis, for instance, generating aggregated profiles + +.. code:: ipython3 + + n_days = 30 + date_start = "2020-01-01" + use_case.date_start = date_start + use_case.initialize(num_days=n_days, force=True) + use_case.generate_daily_load_profiles() + + +.. parsed-literal:: + + You will simulate 30 day(s) from 2020-01-01 00:00:00 until 2020-01-31 00:00:00 + + + + +.. parsed-literal:: + + array([0. , 0. , 0. , ..., 0.002, 0.002, 0.002]) + + .. code:: ipython3 - peak_time_range = calc_peak_time_range( - user_list = use_case.users + profiles = pd.DataFrame( + data=use_case.generate_daily_load_profiles(flat=True), + index=pd.date_range(start=date_start, periods=1440 * n_days, freq="T"), ) - year_behaviour = yearly_pattern() + profiles.plot(title="Usecase") + + + + +.. parsed-literal:: + + + + + + +.. image:: output_17_1.png + + +Generating load profiles for the single users of the usecase +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: ipython3 - n_days = 30 - - - for user in use_case.users: user_profiles = [] - for day in range(n_days): + for day_idx, day in enumerate(use_case.days): profile = user.generate_aggregated_load_profile( - prof_i = day, - peak_time_range = peak_time_range, - Year_behaviour = year_behaviour - ) - + prof_i=day_idx, + peak_time_range=use_case.peak_time_range, + day_type=get_day_type(day), + ) + user_profiles.extend(profile) - - profiles = pd.DataFrame( - data = user_profiles, - index = pd.date_range(start = "2020-01-01",periods = 1440*n_days,freq="T"), + + profiles = pd.DataFrame( + data=user_profiles, + index=pd.date_range(start=date_start, periods=1440 * n_days, freq="T"), ) - - profiles.plot(title = user.user_name) - - + + profiles.plot(title=user.user_name) -.. image:: output_17_0.png +.. image:: output_19_0.png -.. image:: output_17_1.png +.. image:: output_19_1.png +