Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of deprecated User.Appliance class #142

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/notebooks/multi_cycle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"outputs": [],
"source": [
"# creating the appliance\n",
"fridge = household.Appliance(\n",
"fridge = household.add_appliance(\n",
" name=\"Fridge\",\n",
" number=1,\n",
" power=200,\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/multi_cycle/multi_cycle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Creating the user and appliance
.. code:: ipython3

# creating the appliance
fridge = household.Appliance(
fridge = household.add_appliance(
name="Fridge",
number=1,
power=200,
Expand Down
46 changes: 45 additions & 1 deletion ramp/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,51 @@ def _add_appliance_instance(self, appliances):
self.App_list.append(app)

def add_appliance(self, *args, **kwargs):
"""adds an appliance to the user category with all the appliance characteristics in a single function
""""adds an appliance to the user category with all the appliance characteristics in a single function

Parameters
----------
number : int, optional
number of appliances of the specified kind, by default 1

power : Union[float.pd.DataFrame], optional
Power rating of appliance (average). If the appliance has variant daily power, a series (with the size of 366) can be passed., by default 0

num_windows : int [1,2,3], optional
Number of distinct time windows, by default 1

func_time : int[0,1440], optional
total time (minutes) the appliance is on during the day (not dependant on windows). Acceptable values are in range 0 to 1440, by default 0

time_fraction_random_variability : Percentage, optional
percentage of total time of use that is subject to random variability. For time (not for windows), randomizes the total time the appliance is on, by default 0

func_cycle : int[0,1440], optional
minimum time(minutes) the appliance is kept on after switch-on event, by default 1

fixed : str, optional
if 'yes', all the 'n' appliances of this kind are always switched-on together, by default "no"

fixed_cycle : int{0,1,2,3,4}, optional
Number of duty cycle, 0 means continuous power, if not 0 you have to fill the cw (cycle window) parameter (you may define up to 3 cws), by default 0

occasional_use : Percentage, optional
Defines how often the appliance is used, e.g. every second day will be 0.5, by default 1

flat : str{'yes','no'}, optional
allows to model appliances that are not subject to any kind of random variability, such as public lighting, by default "no"

thermal_p_var : Percentage, optional
Range of change of the power of the appliance (e.g. shower not taken at same temparature) or for the power of duty cycles (e.g. for a cooker, AC, heater if external temperature is different…), by default 0

pref_index : int{0,1,2,3}, optional
defines preference index for association with random User daily preference behaviour.This number must be smaller or equal to the value input in user_preference, by default 0

wd_we_type : int{0,1,2}, optional
Specify whether the appliance is used only on weekdays (0), weekend (1) or the whole week (2), by default 2

name : str, optional
the name of the appliance, by default ""


Returns
Expand Down
110 changes: 55 additions & 55 deletions ramp/example/input_file_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""

# Create new user classes
HI = User("high income", 11, 3)
HI = User(user_name="high income", num_users=11, user_preference=3)
User_list.append(HI)

HMI = User("higher middle income", 38, 3)
Expand All @@ -46,43 +46,43 @@
# Create new appliances

# Church
Ch_indoor_bulb = Church.Appliance(10, 26, 1, 210, 0.2, 60, "yes", flat="yes")
Ch_indoor_bulb.windows([1200, 1440], [0, 0], 0.1)
Ch_indoor_bulb = Church.add_appliance(number=10, power=26, num_windows=1, func_time=210, time_fraction_random_variability=0.2, func_cycle=60, fixed="yes", flat="yes")
Ch_indoor_bulb.windows(window_1=[1200, 1440], window_2=[0, 0], random_var_w=0.1)

Ch_outdoor_bulb = Church.Appliance(7, 26, 1, 150, 0.2, 60, "yes", flat="yes")
Ch_outdoor_bulb = Church.add_appliance(7, 26, 1, 150, 0.2, 60, "yes", flat="yes")
Ch_outdoor_bulb.windows([1200, 1440], [0, 0], 0.1)

Ch_speaker = Church.Appliance(1, 100, 1, 150, 0.2, 60)
Ch_speaker = Church.add_appliance(1, 100, 1, 150, 0.2, 60)
Ch_speaker.windows([1200, 1350], [0, 0], 0.1)

# Public lighting
Pub_lights = Public_lighting.Appliance(12, 40, 2, 310, 0.1, 300, "yes", flat="yes")
Pub_lights = Public_lighting.add_appliance(12, 40, 2, 310, 0.1, 300, "yes", flat="yes")
Pub_lights.windows([0, 336], [1110, 1440], 0.2)

Pub_lights_2 = Public_lighting.Appliance(25, 150, 2, 310, 0.1, 300, "yes", flat="yes")
Pub_lights_2 = Public_lighting.add_appliance(25, 150, 2, 310, 0.1, 300, "yes", flat="yes")
Pub_lights_2.windows([0, 336], [1110, 1440], 0.2)


# High-Income
HI_indoor_bulb = HI.Appliance(6, 7, 2, 120, 0.2, 10)
HI_indoor_bulb = HI.add_appliance(6, 7, 2, 120, 0.2, 10)
HI_indoor_bulb.windows([1170, 1440], [0, 30], 0.35)

HI_outdoor_bulb = HI.Appliance(2, 13, 2, 600, 0.2, 10)
HI_outdoor_bulb = HI.add_appliance(2, 13, 2, 600, 0.2, 10)
HI_outdoor_bulb.windows([0, 330], [1170, 1440], 0.35)

HI_TV = HI.Appliance(2, 60, 3, 180, 0.1, 5)
HI_TV = HI.add_appliance(2, 60, 3, 180, 0.1, 5)
HI_TV.windows([720, 900], [1170, 1440], 0.35, [0, 60])

HI_DVD = HI.Appliance(1, 8, 3, 60, 0.1, 5)
HI_DVD = HI.add_appliance(1, 8, 3, 60, 0.1, 5)
HI_DVD.windows([720, 900], [1170, 1440], 0.35, [0, 60])

HI_Antenna = HI.Appliance(1, 8, 3, 120, 0.1, 5)
HI_Antenna = HI.add_appliance(1, 8, 3, 120, 0.1, 5)
HI_Antenna.windows([720, 900], [1170, 1440], 0.35, [0, 60])

HI_Phone_charger = HI.Appliance(5, 2, 2, 300, 0.2, 5)
HI_Phone_charger = HI.add_appliance(5, 2, 2, 300, 0.2, 5)
HI_Phone_charger.windows([1110, 1440], [0, 30], 0.35)

HI_Freezer = HI.Appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HI_Freezer = HI.add_appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HI_Freezer.windows([0, 1440], [0, 0])
HI_Freezer.specific_cycle_1(200, 20, 5, 10)
HI_Freezer.specific_cycle_2(200, 15, 5, 15)
Expand All @@ -91,7 +91,7 @@
[480, 1200], [0, 0], [300, 479], [0, 0], [0, 299], [1201, 1440]
)

HI_Freezer2 = HI.Appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HI_Freezer2 = HI.add_appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HI_Freezer2.windows([0, 1440], [0, 0])
HI_Freezer2.specific_cycle_1(200, 20, 5, 10)
HI_Freezer2.specific_cycle_2(200, 15, 5, 15)
Expand All @@ -100,32 +100,32 @@
[480, 1200], [0, 0], [300, 479], [0, 0], [0, 299], [1201, 1440]
)

HI_Mixer = HI.Appliance(1, 50, 3, 30, 0.1, 1, occasional_use=0.33)
HI_Mixer = HI.add_appliance(1, 50, 3, 30, 0.1, 1, occasional_use=0.33)
HI_Mixer.windows([420, 480], [660, 750], 0.35, [1140, 1200])

# Higher-Middle Income
HMI_indoor_bulb = HMI.Appliance(5, 7, 2, 120, 0.2, 10)
HMI_indoor_bulb = HMI.add_appliance(5, 7, 2, 120, 0.2, 10)
HMI_indoor_bulb.windows([1170, 1440], [0, 30], 0.35)

HMI_outdoor_bulb = HMI.Appliance(2, 13, 2, 600, 0.2, 10)
HMI_outdoor_bulb = HMI.add_appliance(2, 13, 2, 600, 0.2, 10)
HMI_outdoor_bulb.windows([0, 330], [1170, 1440], 0.35)

HMI_TV = HMI.Appliance(1, 60, 2, 120, 0.1, 5)
HMI_TV = HMI.add_appliance(1, 60, 2, 120, 0.1, 5)
HMI_TV.windows([1170, 1440], [0, 60], 0.35)

HMI_DVD = HMI.Appliance(1, 8, 2, 40, 0.1, 5)
HMI_DVD = HMI.add_appliance(1, 8, 2, 40, 0.1, 5)
HMI_DVD.windows([1170, 1440], [0, 60], 0.35)

HMI_Antenna = HMI.Appliance(1, 8, 2, 80, 0.1, 5)
HMI_Antenna = HMI.add_appliance(1, 8, 2, 80, 0.1, 5)
HMI_Antenna.windows([1170, 1440], [0, 60], 0.35)

HMI_Radio = HMI.Appliance(1, 36, 2, 60, 0.1, 5)
HMI_Radio = HMI.add_appliance(1, 36, 2, 60, 0.1, 5)
HMI_Radio.windows([390, 450], [1140, 1260], 0.35)

HMI_Phone_charger = HMI.Appliance(4, 2, 2, 300, 0.2, 5)
HMI_Phone_charger = HMI.add_appliance(4, 2, 2, 300, 0.2, 5)
HMI_Phone_charger.windows([1110, 1440], [0, 30], 0.35)

HMI_Freezer = HMI.Appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HMI_Freezer = HMI.add_appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
HMI_Freezer.windows([0, 1440], [0, 0])
HMI_Freezer.specific_cycle_1(200, 20, 5, 10)
HMI_Freezer.specific_cycle_2(200, 15, 5, 15)
Expand All @@ -134,61 +134,61 @@
[480, 1200], [0, 0], [300, 479], [0, 0], [0, 299], [1201, 1440]
)

HMI_Mixer = HMI.Appliance(1, 50, 3, 30, 0.1, 1, occasional_use=0.33)
HMI_Mixer = HMI.add_appliance(1, 50, 3, 30, 0.1, 1, occasional_use=0.33)
HMI_Mixer.windows([420, 450], [660, 750], 0.35, [1020, 1170])

# Lower-Midlle Income
LMI_indoor_bulb = LMI.Appliance(3, 7, 2, 120, 0.2, 10)
LMI_indoor_bulb = LMI.add_appliance(3, 7, 2, 120, 0.2, 10)
LMI_indoor_bulb.windows([1170, 1440], [0, 30], 0.35)

LMI_outdoor_bulb = LMI.Appliance(2, 13, 2, 600, 0.2, 10)
LMI_outdoor_bulb = LMI.add_appliance(2, 13, 2, 600, 0.2, 10)
LMI_outdoor_bulb.windows([0, 330], [1170, 1440], 0.35)

LMI_TV = LMI.Appliance(1, 60, 3, 90, 0.1, 5)
LMI_TV = LMI.add_appliance(1, 60, 3, 90, 0.1, 5)
LMI_TV.windows([450, 660], [720, 840], 0.35, [1170, 1440])

LMI_DVD = LMI.Appliance(1, 8, 3, 30, 0.1, 5)
LMI_DVD = LMI.add_appliance(1, 8, 3, 30, 0.1, 5)
LMI_DVD.windows([450, 660], [720, 840], 0.35, [1170, 1440])

LMI_Antenna = LMI.Appliance(1, 8, 3, 60, 0.1, 5)
LMI_Antenna = LMI.add_appliance(1, 8, 3, 60, 0.1, 5)
LMI_Antenna.windows([450, 660], [720, 840], 0.35, [1170, 1440])

LMI_Phone_charger = LMI.Appliance(4, 2, 1, 300, 0.2, 5)
LMI_Phone_charger = LMI.add_appliance(4, 2, 1, 300, 0.2, 5)
LMI_Phone_charger.windows([1020, 1440], [0, 0], 0.35)

LMI_Mixer = LMI.Appliance(1, 50, 2, 30, 0.1, 1, occasional_use=0.33)
LMI_Mixer = LMI.add_appliance(1, 50, 2, 30, 0.1, 1, occasional_use=0.33)
LMI_Mixer.windows([660, 750], [1110, 1200], 0.35)

# Low Income
LI_indoor_bulb = LI.Appliance(2, 7, 2, 120, 0.2, 10)
LI_indoor_bulb = LI.add_appliance(2, 7, 2, 120, 0.2, 10)
LI_indoor_bulb.windows([1170, 1440], [0, 30], 0.35)

LI_outdoor_bulb = LI.Appliance(1, 13, 2, 600, 0.2, 10)
LI_outdoor_bulb = LI.add_appliance(1, 13, 2, 600, 0.2, 10)
LI_outdoor_bulb.windows([0, 330], [1170, 1440], 0.35)

LI_TV = LI.Appliance(1, 60, 3, 90, 0.1, 5)
LI_TV = LI.add_appliance(1, 60, 3, 90, 0.1, 5)
LI_TV.windows([750, 840], [1170, 1440], 0.35, [0, 30])

LI_DVD = LI.Appliance(1, 8, 3, 30, 0.1, 5)
LI_DVD = LI.add_appliance(1, 8, 3, 30, 0.1, 5)
LI_DVD.windows([750, 840], [1170, 1440], 0.35, [0, 30])

LI_Antenna = LI.Appliance(1, 8, 3, 60, 0.1, 5)
LI_Antenna = LI.add_appliance(1, 8, 3, 60, 0.1, 5)
LI_Antenna.windows([750, 840], [1170, 1440], 0.35, [0, 30])

LI_Phone_charger = LI.Appliance(2, 2, 1, 300, 0.2, 5)
LI_Phone_charger = LI.add_appliance(2, 2, 1, 300, 0.2, 5)
LI_Phone_charger.windows([1080, 1440], [0, 0], 0.35)

# Hospital
Ho_indoor_bulb = Hospital.Appliance(12, 7, 2, 690, 0.2, 10)
Ho_indoor_bulb = Hospital.add_appliance(12, 7, 2, 690, 0.2, 10)
Ho_indoor_bulb.windows([480, 720], [870, 1440], 0.35)

Ho_outdoor_bulb = Hospital.Appliance(1, 13, 2, 690, 0.2, 10)
Ho_outdoor_bulb = Hospital.add_appliance(1, 13, 2, 690, 0.2, 10)
Ho_outdoor_bulb.windows([0, 330], [1050, 1440], 0.35)

Ho_Phone_charger = Hospital.Appliance(8, 2, 2, 300, 0.2, 5)
Ho_Phone_charger = Hospital.add_appliance(8, 2, 2, 300, 0.2, 5)
Ho_Phone_charger.windows([480, 720], [900, 1440], 0.35)

Ho_Fridge = Hospital.Appliance(1, 150, 1, 1440, 0, 30, "yes", 3)
Ho_Fridge = Hospital.add_appliance(1, 150, 1, 1440, 0, 30, "yes", 3)
Ho_Fridge.windows([0, 1440], [0, 0])
Ho_Fridge.specific_cycle_1(150, 20, 5, 10)
Ho_Fridge.specific_cycle_2(150, 15, 5, 15)
Expand All @@ -197,7 +197,7 @@
[580, 1200], [0, 0], [420, 579], [0, 0], [0, 419], [1201, 1440]
)

Ho_Fridge2 = Hospital.Appliance(1, 150, 1, 1440, 0, 30, "yes", 3)
Ho_Fridge2 = Hospital.add_appliance(1, 150, 1, 1440, 0, 30, "yes", 3)
Ho_Fridge2.windows([0, 1440], [0, 0])
Ho_Fridge2.specific_cycle_1(150, 20, 5, 10)
Ho_Fridge2.specific_cycle_2(150, 15, 5, 15)
Expand All @@ -206,7 +206,7 @@
[580, 1200], [0, 0], [420, 579], [0, 0], [0, 299], [1201, 1440]
)

Ho_Fridge3 = Hospital.Appliance(1, 150, 1, 1440, 0.1, 30, "yes", 3)
Ho_Fridge3 = Hospital.add_appliance(1, 150, 1, 1440, 0.1, 30, "yes", 3)
Ho_Fridge3.windows([0, 1440], [0, 0])
Ho_Fridge3.specific_cycle_1(150, 20, 5, 10)
Ho_Fridge3.specific_cycle_2(150, 15, 5, 15)
Expand All @@ -215,29 +215,29 @@
[580, 1200], [0, 0], [420, 479], [0, 0], [0, 419], [1201, 1440]
)

Ho_PC = Hospital.Appliance(2, 50, 2, 300, 0.1, 10)
Ho_PC = Hospital.add_appliance(2, 50, 2, 300, 0.1, 10)
Ho_PC.windows([480, 720], [1050, 1440], 0.35)

Ho_Mixer = Hospital.Appliance(1, 50, 2, 60, 0.1, 1, occasional_use=0.33)
Ho_Mixer = Hospital.add_appliance(1, 50, 2, 60, 0.1, 1, occasional_use=0.33)
Ho_Mixer.windows([480, 720], [1050, 1440], 0.35)

# School
S_indoor_bulb = School.Appliance(8, 7, 1, 60, 0.2, 10)
S_indoor_bulb = School.add_appliance(8, 7, 1, 60, 0.2, 10)
S_indoor_bulb.windows([1020, 1080], [0, 0], 0.35)

S_outdoor_bulb = School.Appliance(6, 13, 1, 60, 0.2, 10)
S_outdoor_bulb = School.add_appliance(6, 13, 1, 60, 0.2, 10)
S_outdoor_bulb.windows([1020, 1080], [0, 0], 0.35)

S_Phone_charger = School.Appliance(5, 2, 2, 180, 0.2, 5)
S_Phone_charger = School.add_appliance(5, 2, 2, 180, 0.2, 5)
S_Phone_charger.windows([510, 750], [810, 1080], 0.35)

S_PC = School.Appliance(18, 50, 2, 210, 0.1, 10)
S_PC = School.add_appliance(18, 50, 2, 210, 0.1, 10)
S_PC.windows([510, 750], [810, 1080], 0.35)

S_Printer = School.Appliance(1, 20, 2, 30, 0.1, 5)
S_Printer = School.add_appliance(1, 20, 2, 30, 0.1, 5)
S_Printer.windows([510, 750], [810, 1080], 0.35)

S_Freezer = School.Appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
S_Freezer = School.add_appliance(1, 200, 1, 1440, 0, 30, "yes", 3)
S_Freezer.windows([0, 1440])
S_Freezer.specific_cycle_1(200, 20, 5, 10)
S_Freezer.specific_cycle_2(200, 15, 5, 15)
Expand All @@ -246,13 +246,13 @@
[580, 1200], [0, 0], [510, 579], [0, 0], [0, 509], [1201, 1440]
)

S_TV = School.Appliance(1, 60, 2, 120, 0.1, 5, occasional_use=0.5)
S_TV = School.add_appliance(1, 60, 2, 120, 0.1, 5, occasional_use=0.5)
S_TV.windows([510, 750], [810, 1080], 0.35)

S_DVD = School.Appliance(1, 8, 2, 120, 0.1, 5, occasional_use=0.5)
S_DVD = School.add_appliance(1, 8, 2, 120, 0.1, 5, occasional_use=0.5)
S_DVD.windows([510, 750], [810, 1080], 0.35)

S_Stereo = School.Appliance(1, 150, 2, 90, 0.1, 5, occasional_use=0.33)
S_Stereo = School.add_appliance(1, 150, 2, 90, 0.1, 5, occasional_use=0.33)
S_Stereo.windows([510, 750], [810, 1080], 0.35)

if __name__ == "__main__":
Expand Down
8 changes: 3 additions & 5 deletions ramp/example/input_file_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
"""

# Create new user classes
HH = User("generic households", 1)
HH = User(user_name="generic households", num_users=1)
User_list.append(HH)

HH_shower_P = pd.read_csv("ramp/example/shower_P.csv")

# High-Income
HH_shower = HH.Appliance(1, HH_shower_P, 2, 15, 0.1, 3, thermal_P_var=0.2)
HH_shower.windows([390, 540], [1080, 1200], 0.2)
HH_shower = HH.add_appliance(number=1, power=HH_shower_P, num_windows=2, func_time=15, time_fraction_random_variability=0.1, func_cycle=3, thermal_p_var=0.2)
HH_shower.windows(window_1=[390, 540], window_2=[1080, 1200], random_var_w=0.2)


if __name__ == "__main__":
Expand Down
Loading
Loading