From 0a294658c53f499bcc3940507e52a453efd8308e Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Mon, 6 May 2024 13:58:19 +0200 Subject: [PATCH 1/8] Remove deprecated code usage --- docs/notebooks/multi_cycle.ipynb | 2 +- ramp/example/input_file_1.py | 106 +++++++++++++++---------------- ramp/example/input_file_2.py | 2 +- ramp/example/input_file_3.py | 24 +++---- 4 files changed, 67 insertions(+), 67 deletions(-) diff --git a/docs/notebooks/multi_cycle.ipynb b/docs/notebooks/multi_cycle.ipynb index 8069cc07..cfa9e4a3 100644 --- a/docs/notebooks/multi_cycle.ipynb +++ b/docs/notebooks/multi_cycle.ipynb @@ -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", diff --git a/ramp/example/input_file_1.py b/ramp/example/input_file_1.py index 8ff7cd6b..ae1179f4 100644 --- a/ramp/example/input_file_1.py +++ b/ramp/example/input_file_1.py @@ -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 = Church.add_appliance(10, 26, 1, 210, 0.2, 60, "yes", flat="yes") Ch_indoor_bulb.windows([1200, 1440], [0, 0], 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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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__": diff --git a/ramp/example/input_file_2.py b/ramp/example/input_file_2.py index 4e738882..ef01a01c 100644 --- a/ramp/example/input_file_2.py +++ b/ramp/example/input_file_2.py @@ -24,7 +24,7 @@ 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 = HH.add_appliance(1, HH_shower_P, 2, 15, 0.1, 3, thermal_P_var=0.2) HH_shower.windows([390, 540], [1080, 1200], 0.2) diff --git a/ramp/example/input_file_3.py b/ramp/example/input_file_3.py index 1572e526..be145aee 100644 --- a/ramp/example/input_file_3.py +++ b/ramp/example/input_file_3.py @@ -24,70 +24,70 @@ # Create Cooking appliances -HH_lunch1_soup = HH.Appliance( +HH_lunch1_soup = HH.add_appliance( 1, 1800, 2, 70, 0.15, 60, thermal_P_var=0.2, pref_index=1, fixed_cycle=1 ) HH_lunch1_soup.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch1_soup.specific_cycle_1(1800, 10, 750, 60, 0.15) HH_lunch1_soup.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch2_rice = HH.Appliance( +HH_lunch2_rice = HH.add_appliance( 1, 1800, 2, 25, 0.15, 20, thermal_P_var=0.2, pref_index=2, fixed_cycle=1 ) HH_lunch2_rice.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch2_rice.specific_cycle_1(1800, 10, 750, 15, 0.15) HH_lunch2_rice.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch2_egg = HH.Appliance(1, 1200, 2, 3, 0.2, 3, thermal_P_var=0.2, pref_index=2) +HH_lunch2_egg = HH.add_appliance(1, 1200, 2, 3, 0.2, 3, thermal_P_var=0.2, pref_index=2) HH_lunch2_egg.windows([12 * 60, 15 * 60], [0, 0], 0.15) -HH_lunch2_platano = HH.Appliance( +HH_lunch2_platano = HH.add_appliance( 1, 1800, 2, 10, 0.15, 5, thermal_P_var=0.2, pref_index=2, fixed_cycle=1 ) HH_lunch2_platano.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch2_platano.specific_cycle_1(1800, 5, 1200, 5, 0.15) HH_lunch2_platano.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch2_meat = HH.Appliance(1, 1200, 2, 7, 0.15, 3, thermal_P_var=0.2, pref_index=2) +HH_lunch2_meat = HH.add_appliance(1, 1200, 2, 7, 0.15, 3, thermal_P_var=0.2, pref_index=2) HH_lunch2_meat.windows([12 * 60, 15 * 60], [0, 0], 0.15) -HH_lunch3_beansnrice = HH.Appliance( +HH_lunch3_beansnrice = HH.add_appliance( 1, 1800, 2, 45, 0.2, 30, thermal_P_var=0.2, pref_index=3, fixed_cycle=1 ) HH_lunch3_beansnrice.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch3_beansnrice.specific_cycle_1(1800, 10, 750, 35, 0.2) HH_lunch3_beansnrice.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch3_meat = HH.Appliance(1, 1200, 2, 10, 0.2, 5, thermal_P_var=0.2, pref_index=3) +HH_lunch3_meat = HH.add_appliance(1, 1200, 2, 10, 0.2, 5, thermal_P_var=0.2, pref_index=3) HH_lunch3_meat.windows([12 * 60, 15 * 60], [0, 0], 0.15) -HH_lunch_yuca = HH.Appliance( +HH_lunch_yuca = HH.add_appliance( 1, 1800, 1, 25, 0.15, 10, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 ) HH_lunch_yuca.windows([13 * 60, 14 * 60], [0, 0], 0.15) HH_lunch_yuca.specific_cycle_1(1800, 10, 750, 15, 0.15) HH_lunch_yuca.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_breakfast_huminta = HH.Appliance( +HH_breakfast_huminta = HH.add_appliance( 1, 1800, 1, 65, 0.15, 50, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 ) HH_breakfast_huminta.windows([6 * 60, 9 * 60], [0, 0], 0.15) HH_breakfast_huminta.specific_cycle_1(1800, 5, 750, 60, 0.15) HH_breakfast_huminta.cycle_behaviour([6 * 60, 9 * 60], [0, 0]) -HH_breakfast_bread = HH.Appliance( +HH_breakfast_bread = HH.add_appliance( 1, 1800, 1, 15, 0.15, 10, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 ) HH_breakfast_bread.windows([6 * 60, 9 * 60], [0, 0], 0.15) HH_breakfast_bread.specific_cycle_1(1800, 10, 1200, 5, 0.15) HH_breakfast_bread.cycle_behaviour([6 * 60, 9 * 60], [0, 0]) -HH_breakfast_coffee = HH.Appliance( +HH_breakfast_coffee = HH.add_appliance( 1, 1800, 1, 5, 0.15, 2, thermal_P_var=0.2, pref_index=0 ) HH_breakfast_coffee.windows([6 * 60, 9 * 60], [0, 0], 0.15) -HH_mate = HH.Appliance(1, 1800, 1, 30, 0.3, 2, thermal_P_var=0.2, pref_index=0) +HH_mate = HH.add_appliance(1, 1800, 1, 30, 0.3, 2, thermal_P_var=0.2, pref_index=0) HH_mate.windows([7 * 60, 20 * 60], [0, 0], 0.15) From 458487cae71b5a566d9116aa5350069bc625e95c Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Mon, 6 May 2024 13:58:47 +0200 Subject: [PATCH 2/8] Copy the appliance parameter docstrings to add_appliance docstring --- ramp/core/core.py | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/ramp/core/core.py b/ramp/core/core.py index 7e290969..3814d75d 100644 --- a/ramp/core/core.py +++ b/ramp/core/core.py @@ -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 From 1686ef30e51bcc755ea4449ace6dcf87529bc2ee Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 00:10:58 +0200 Subject: [PATCH 3/8] Correct argument name typo --- ramp/example/input_file_2.py | 2 +- ramp/example/input_file_3.py | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ramp/example/input_file_2.py b/ramp/example/input_file_2.py index ef01a01c..36142f8b 100644 --- a/ramp/example/input_file_2.py +++ b/ramp/example/input_file_2.py @@ -24,7 +24,7 @@ HH_shower_P = pd.read_csv("ramp/example/shower_P.csv") # High-Income -HH_shower = HH.add_appliance(1, HH_shower_P, 2, 15, 0.1, 3, thermal_P_var=0.2) +HH_shower = HH.add_appliance(1, HH_shower_P, 2, 15, 0.1, 3, thermal_p_var=0.2) HH_shower.windows([390, 540], [1080, 1200], 0.2) diff --git a/ramp/example/input_file_3.py b/ramp/example/input_file_3.py index be145aee..51dc482f 100644 --- a/ramp/example/input_file_3.py +++ b/ramp/example/input_file_3.py @@ -25,69 +25,73 @@ # Create Cooking appliances HH_lunch1_soup = HH.add_appliance( - 1, 1800, 2, 70, 0.15, 60, thermal_P_var=0.2, pref_index=1, fixed_cycle=1 + 1, 1800, 2, 70, 0.15, 60, thermal_p_var=0.2, pref_index=1, fixed_cycle=1 ) HH_lunch1_soup.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch1_soup.specific_cycle_1(1800, 10, 750, 60, 0.15) HH_lunch1_soup.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) HH_lunch2_rice = HH.add_appliance( - 1, 1800, 2, 25, 0.15, 20, thermal_P_var=0.2, pref_index=2, fixed_cycle=1 + 1, 1800, 2, 25, 0.15, 20, thermal_p_var=0.2, pref_index=2, fixed_cycle=1 ) HH_lunch2_rice.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch2_rice.specific_cycle_1(1800, 10, 750, 15, 0.15) HH_lunch2_rice.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch2_egg = HH.add_appliance(1, 1200, 2, 3, 0.2, 3, thermal_P_var=0.2, pref_index=2) +HH_lunch2_egg = HH.add_appliance(1, 1200, 2, 3, 0.2, 3, thermal_p_var=0.2, pref_index=2) HH_lunch2_egg.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch2_platano = HH.add_appliance( - 1, 1800, 2, 10, 0.15, 5, thermal_P_var=0.2, pref_index=2, fixed_cycle=1 + 1, 1800, 2, 10, 0.15, 5, thermal_p_var=0.2, pref_index=2, fixed_cycle=1 ) HH_lunch2_platano.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch2_platano.specific_cycle_1(1800, 5, 1200, 5, 0.15) HH_lunch2_platano.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch2_meat = HH.add_appliance(1, 1200, 2, 7, 0.15, 3, thermal_P_var=0.2, pref_index=2) +HH_lunch2_meat = HH.add_appliance( + 1, 1200, 2, 7, 0.15, 3, thermal_p_var=0.2, pref_index=2 +) HH_lunch2_meat.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch3_beansnrice = HH.add_appliance( - 1, 1800, 2, 45, 0.2, 30, thermal_P_var=0.2, pref_index=3, fixed_cycle=1 + 1, 1800, 2, 45, 0.2, 30, thermal_p_var=0.2, pref_index=3, fixed_cycle=1 ) HH_lunch3_beansnrice.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch3_beansnrice.specific_cycle_1(1800, 10, 750, 35, 0.2) HH_lunch3_beansnrice.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) -HH_lunch3_meat = HH.add_appliance(1, 1200, 2, 10, 0.2, 5, thermal_P_var=0.2, pref_index=3) +HH_lunch3_meat = HH.add_appliance( + 1, 1200, 2, 10, 0.2, 5, thermal_p_var=0.2, pref_index=3 +) HH_lunch3_meat.windows([12 * 60, 15 * 60], [0, 0], 0.15) HH_lunch_yuca = HH.add_appliance( - 1, 1800, 1, 25, 0.15, 10, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 + 1, 1800, 1, 25, 0.15, 10, thermal_p_var=0.2, pref_index=0, fixed_cycle=1 ) HH_lunch_yuca.windows([13 * 60, 14 * 60], [0, 0], 0.15) HH_lunch_yuca.specific_cycle_1(1800, 10, 750, 15, 0.15) HH_lunch_yuca.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) HH_breakfast_huminta = HH.add_appliance( - 1, 1800, 1, 65, 0.15, 50, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 + 1, 1800, 1, 65, 0.15, 50, thermal_p_var=0.2, pref_index=0, fixed_cycle=1 ) HH_breakfast_huminta.windows([6 * 60, 9 * 60], [0, 0], 0.15) HH_breakfast_huminta.specific_cycle_1(1800, 5, 750, 60, 0.15) HH_breakfast_huminta.cycle_behaviour([6 * 60, 9 * 60], [0, 0]) HH_breakfast_bread = HH.add_appliance( - 1, 1800, 1, 15, 0.15, 10, thermal_P_var=0.2, pref_index=0, fixed_cycle=1 + 1, 1800, 1, 15, 0.15, 10, thermal_p_var=0.2, pref_index=0, fixed_cycle=1 ) HH_breakfast_bread.windows([6 * 60, 9 * 60], [0, 0], 0.15) HH_breakfast_bread.specific_cycle_1(1800, 10, 1200, 5, 0.15) HH_breakfast_bread.cycle_behaviour([6 * 60, 9 * 60], [0, 0]) HH_breakfast_coffee = HH.add_appliance( - 1, 1800, 1, 5, 0.15, 2, thermal_P_var=0.2, pref_index=0 + 1, 1800, 1, 5, 0.15, 2, thermal_p_var=0.2, pref_index=0 ) HH_breakfast_coffee.windows([6 * 60, 9 * 60], [0, 0], 0.15) -HH_mate = HH.add_appliance(1, 1800, 1, 30, 0.3, 2, thermal_P_var=0.2, pref_index=0) +HH_mate = HH.add_appliance(1, 1800, 1, 30, 0.3, 2, thermal_p_var=0.2, pref_index=0) HH_mate.windows([7 * 60, 20 * 60], [0, 0], 0.15) From f4cd862bd2f6747dacaa3476609c0d63fd4e238f Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 00:19:58 +0200 Subject: [PATCH 4/8] Update the documentation --- docs/source/examples/multi_cycle/multi_cycle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/examples/multi_cycle/multi_cycle.rst b/docs/source/examples/multi_cycle/multi_cycle.rst index 248f9abc..867e5339 100644 --- a/docs/source/examples/multi_cycle/multi_cycle.rst +++ b/docs/source/examples/multi_cycle/multi_cycle.rst @@ -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, From 505e4aae9a3edc61be746326a00b529fac29b784 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 00:39:05 +0200 Subject: [PATCH 5/8] Explicit the arguments in methods the example files Do this only for the first occurence as there are many appliances and users in examples 1 and 3 --- ramp/example/input_file_1.py | 6 +++--- ramp/example/input_file_2.py | 8 +++----- ramp/example/input_file_3.py | 10 +++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ramp/example/input_file_1.py b/ramp/example/input_file_1.py index ae1179f4..9d83c176 100644 --- a/ramp/example/input_file_1.py +++ b/ramp/example/input_file_1.py @@ -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) @@ -46,8 +46,8 @@ # Create new appliances # Church -Ch_indoor_bulb = Church.add_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.add_appliance(7, 26, 1, 150, 0.2, 60, "yes", flat="yes") Ch_outdoor_bulb.windows([1200, 1440], [0, 0], 0.1) diff --git a/ramp/example/input_file_2.py b/ramp/example/input_file_2.py index 36142f8b..83878573 100644 --- a/ramp/example/input_file_2.py +++ b/ramp/example/input_file_2.py @@ -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.add_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__": diff --git a/ramp/example/input_file_3.py b/ramp/example/input_file_3.py index 51dc482f..74441eaf 100644 --- a/ramp/example/input_file_3.py +++ b/ramp/example/input_file_3.py @@ -17,7 +17,7 @@ """ # Create new user classes -HH = User("generic household", 1, 3) +HH = User(user_name="generic household", num_users=1, user_preference=3) User_list.append(HH) # Create new appliances @@ -25,11 +25,11 @@ # Create Cooking appliances HH_lunch1_soup = HH.add_appliance( - 1, 1800, 2, 70, 0.15, 60, thermal_p_var=0.2, pref_index=1, fixed_cycle=1 + number=1, power=1800, num_windows=2, func_time=70, time_fraction_random_variability=0.15, func_cycle=60, thermal_p_var=0.2, pref_index=1, fixed_cycle=1 ) -HH_lunch1_soup.windows([12 * 60, 15 * 60], [0, 0], 0.15) -HH_lunch1_soup.specific_cycle_1(1800, 10, 750, 60, 0.15) -HH_lunch1_soup.cycle_behaviour([12 * 60, 15 * 60], [0, 0]) +HH_lunch1_soup.windows(window_1=[12 * 60, 15 * 60], window_2=[0, 0], random_var_w=0.15) +HH_lunch1_soup.specific_cycle_1(p_11=1800, t_11=10, p_12=750, t_12=60, r_c1=0.15) +HH_lunch1_soup.cycle_behaviour(cw11=[12 * 60, 15 * 60], cw12=[0, 0]) HH_lunch2_rice = HH.add_appliance( 1, 1800, 2, 25, 0.15, 20, thermal_p_var=0.2, pref_index=2, fixed_cycle=1 From 681388ef7800eb2dc2982dff2d1ebb0d219e19e6 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 14:46:09 +0200 Subject: [PATCH 6/8] Freeze black version for CI and add jupyter linting --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index edfa4dc0..b3a0c2f1 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -26,7 +26,7 @@ jobs: - name: Install black run: | python -m pip install --upgrade pip - pip install black + pip install black[jupyter]==24.4.2 - name: Lint with black run: | black . --check From 43883cea5ca95727805d671f05dcf63e6327be26 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 14:47:43 +0200 Subject: [PATCH 7/8] Lint with black --- docs/notebooks/cooking_app.ipynb | 35 ++++++++++++++++------------- docs/notebooks/fixed_flat_app.ipynb | 21 ++++++++--------- docs/notebooks/multi_cycle.ipynb | 26 ++++++--------------- docs/notebooks/occasional_use.ipynb | 34 +++++++++++++--------------- docs/notebooks/random_seed.ipynb | 32 ++++++++++++-------------- docs/notebooks/simple_bulb.ipynb | 34 +++++++++++++--------------- docs/notebooks/thermal_app.ipynb | 31 +++++++++++++------------ ramp/core/core.py | 2 +- ramp/example/input_file_1.py | 15 +++++++++++-- ramp/example/input_file_2.py | 10 ++++++++- ramp/example/input_file_3.py | 10 ++++++++- 11 files changed, 129 insertions(+), 121 deletions(-) diff --git a/docs/notebooks/cooking_app.ipynb b/docs/notebooks/cooking_app.ipynb index c61a2b1c..6eb6aa3d 100644 --- a/docs/notebooks/cooking_app.ipynb +++ b/docs/notebooks/cooking_app.ipynb @@ -93,20 +93,20 @@ "outputs": [], "source": [ "# soup for lunch\n", - "lunch_window = [12 * 60, 12 * 60+26]\n", + "lunch_window = [12 * 60, 12 * 60 + 26]\n", "\n", "soup_1 = user_1.add_appliance(\n", " name=\"soup for lunch\",\n", - " power=1200, # nominal power of appliance\n", - " func_time=25, # the cooking time\n", - " func_cycle=25, # we always need 25 minute for cooking\n", - " fixed_cycle=1, # the cookstove is not a continus power usage appliance, it has cycles as mentioned earlier \n", - " window_1=lunch_window, # lunch is always prepared from 12\n", + " power=1200, # nominal power of appliance\n", + " func_time=25, # the cooking time\n", + " func_cycle=25, # we always need 25 minute for cooking\n", + " fixed_cycle=1, # the cookstove is not a continus power usage appliance, it has cycles as mentioned earlier\n", + " window_1=lunch_window, # lunch is always prepared from 12\n", " p_11=1200, # power of the first cycle\n", " t_11=5, # time needed for the first cycle\n", " p_12=750, # power of the second cycle\n", " t_12=20, # time needed for the second cycle\n", - " cw11=lunch_window, # the time window of the working cycle \n", + " cw11=lunch_window, # the time window of the working cycle\n", ")" ] }, @@ -194,10 +194,9 @@ "number_of_days = 5\n", "user_1_profiles = {}\n", "user_2_profiles = {}\n", - "for day in range(1,number_of_days+1):\n", + "for day in range(1, number_of_days + 1):\n", " user_1_profiles[f\"day {day}\"] = pd.Series(user_1.generate_single_load_profile())\n", - " user_2_profiles[f\"day {day}\"] = pd.Series(user_2.generate_single_load_profile())\n", - " " + " user_2_profiles[f\"day {day}\"] = pd.Series(user_2.generate_single_load_profile())" ] }, { @@ -218,17 +217,21 @@ } ], "source": [ - "fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) \n", + "fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4))\n", "\n", "\n", "i = 0\n", "for name, df in dict(\n", - " user_1_profiles=pd.concat(user_1_profiles,axis=1).iloc[lunch_window[0]-5:lunch_window[1]+5], # take only the lunch window\n", - " user_2_profiles=pd.concat(user_2_profiles,axis=1).iloc[lunch_window[0]-5:lunch_window[1]+5]# take only the lunch window\n", - " ).items():\n", - " df.plot(ax=axes[i],legend=True)\n", + " user_1_profiles=pd.concat(user_1_profiles, axis=1).iloc[\n", + " lunch_window[0] - 5 : lunch_window[1] + 5\n", + " ], # take only the lunch window\n", + " user_2_profiles=pd.concat(user_2_profiles, axis=1).iloc[\n", + " lunch_window[0] - 5 : lunch_window[1] + 5\n", + " ], # take only the lunch window\n", + ").items():\n", + " df.plot(ax=axes[i], legend=True)\n", " axes[i].set_title(name)\n", - " i+=1\n", + " i += 1\n", "\n", "plt.tight_layout()\n", "plt.show()" diff --git a/docs/notebooks/fixed_flat_app.ipynb b/docs/notebooks/fixed_flat_app.ipynb index f6325095..3a2791ed 100644 --- a/docs/notebooks/fixed_flat_app.ipynb +++ b/docs/notebooks/fixed_flat_app.ipynb @@ -69,8 +69,8 @@ " func_cycle=60,\n", " fixed=\"yes\", # This means all the 'n' appliances of this kind are always switched-on together\n", " flat=\"yes\", # This means the appliance is not subject to random variability in terms of total usage time\n", - " window_1 = [1200, 1440], # from 20:00 to 24:00\n", - ")\n" + " window_1=[1200, 1440], # from 20:00 to 24:00\n", + ")" ] }, { @@ -109,14 +109,12 @@ ], "source": [ "school_case = UseCase(\n", - " users=[school], # users of the usecase\n", - " date_start=\"2023-01-01\", # start date\n", - " )\n", + " users=[school], # users of the usecase\n", + " date_start=\"2023-01-01\", # start date\n", + ")\n", "\n", "# when both date_start and date_end are not given, you need to initialize the usecase by this method and by passing the number of days as num_days\n", - "school_case.initialize(\n", - " num_days=7\n", - " )" + "school_case.initialize(num_days=7)" ] }, { @@ -221,12 +219,11 @@ } ], "source": [ + "fig, axes = plt.subplots(nrows=1, ncols=4, figsize=(12, 4))\n", "\n", - "fig, axes = plt.subplots(nrows=1, ncols=4, figsize=(12, 4)) \n", "\n", - "\n", - "for i, df in enumerate([no_fix_no_flat,fix_no_flat,fixed_flat,no_fixed_flat]):\n", - " df.plot(ax=axes[i],legend=False)\n", + "for i, df in enumerate([no_fix_no_flat, fix_no_flat, fixed_flat, no_fixed_flat]):\n", + " df.plot(ax=axes[i], legend=False)\n", " axes[i].set_title(df.columns[0])\n", "\n", "\n", diff --git a/docs/notebooks/multi_cycle.ipynb b/docs/notebooks/multi_cycle.ipynb index cfa9e4a3..1b7c1414 100644 --- a/docs/notebooks/multi_cycle.ipynb +++ b/docs/notebooks/multi_cycle.ipynb @@ -123,30 +123,18 @@ "# assiging the specific cycles\n", "# first cycle: standard cycle\n", "fridge.specific_cycle_1(\n", - " p_11=200, # power level for the first operation segment\n", + " p_11=200, # power level for the first operation segment\n", " t_11=10, # duration of the first operation segment\n", - " p_12=5, # power level for the second operation segment\n", + " p_12=5, # power level for the second operation segment\n", " t_12=20, # duration of the second operation segment\n", - " r_c1=0 # random variability assigned to the duration of each segment\n", + " r_c1=0, # random variability assigned to the duration of each segment\n", ")\n", "\n", "# second cycle: intermediate cycle\n", - "fridge.specific_cycle_2(\n", - " p_21=200,\n", - " t_21=15,\n", - " p_22=5,\n", - " t_22=15,\n", - " r_c2=0\n", - ")\n", + "fridge.specific_cycle_2(p_21=200, t_21=15, p_22=5, t_22=15, r_c2=0)\n", "\n", "# third cycle: intensive cycle\n", - "fridge.specific_cycle_3(\n", - " p_31=200,\n", - " t_31=20,\n", - " p_32=5,\n", - " t_32=10,\n", - " r_c3=0\n", - ")" + "fridge.specific_cycle_3(p_31=200, t_31=20, p_32=5, t_32=10, r_c3=0)" ] }, { @@ -166,7 +154,7 @@ "source": [ "# defining cycle behaviour\n", "fridge.cycle_behaviour(\n", - " cw11=[0, 299], cw12=[1201, 1440], cw21=[300, 479], cw31=[480, 1200]\n", + " cw11=[0, 299], cw12=[1201, 1440], cw21=[300, 479], cw31=[480, 1200]\n", ")" ] }, @@ -198,7 +186,7 @@ "source": [ "# days to build the profiles\n", "days = [\n", - " \"2020-12-16\", # a day in the 'Hot' season, assuming a location in the Southern hemisphere\n", + " \"2020-12-16\", # a day in the 'Hot' season, assuming a location in the Southern hemisphere\n", "]\n", "\n", "profiles = pd.DataFrame(index=range(0, 1440), columns=days)\n", diff --git a/docs/notebooks/occasional_use.ipynb b/docs/notebooks/occasional_use.ipynb index 12aaff88..c2f03638 100644 --- a/docs/notebooks/occasional_use.ipynb +++ b/docs/notebooks/occasional_use.ipynb @@ -62,10 +62,10 @@ " number=1,\n", " power=50,\n", " num_windows=1,\n", - " func_time=210, # 3.5 hours\n", - " func_cycle=210, \n", + " func_time=210, # 3.5 hours\n", + " func_cycle=210,\n", " occasional_use=0.5, # 50% chance of occasional use,\n", - " window_1=[480, 750], # start from 8AM\n", + " window_1=[480, 750], # start from 8AM\n", ")" ] }, @@ -81,10 +81,10 @@ " number=1,\n", " power=50,\n", " num_windows=1,\n", - " func_time=210, # 3.5 hours\n", - " func_cycle=210, \n", + " func_time=210, # 3.5 hours\n", + " func_cycle=210,\n", " occasional_use=1, # always present in the mix of appliances,\n", - " window_1=[480, 750], # start from 8AM\n", + " window_1=[480, 750], # start from 8AM\n", ")" ] }, @@ -117,14 +117,10 @@ "household_profiles = []\n", "school_profiles = []\n", "\n", - "for day in range(1,number_of_days+1):\n", - " household_profiles.extend(\n", - " household.generate_single_load_profile(prof_i=day)\n", - " )\n", + "for day in range(1, number_of_days + 1):\n", + " household_profiles.extend(household.generate_single_load_profile(prof_i=day))\n", "\n", - " school_profiles.extend(\n", - " school.generate_single_load_profile(prof_i=day)\n", - " )" + " school_profiles.extend(school.generate_single_load_profile(prof_i=day))" ] }, { @@ -145,20 +141,20 @@ } ], "source": [ - "fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) \n", + "fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4))\n", "\n", "\n", "i = 0\n", "for name, df in dict(\n", " household_profiles=pd.DataFrame(household_profiles),\n", - " school_profiles=pd.DataFrame(school_profiles)\n", - " ).items():\n", - " df.plot(ax=axes[i],legend=False)\n", + " school_profiles=pd.DataFrame(school_profiles),\n", + ").items():\n", + " df.plot(ax=axes[i], legend=False)\n", " axes[i].set_title(name)\n", - " i+=1\n", + " i += 1\n", "\n", "plt.tight_layout()\n", - "plt.show()\n" + "plt.show()" ] }, { diff --git a/docs/notebooks/random_seed.ipynb b/docs/notebooks/random_seed.ipynb index c8213b31..556af272 100644 --- a/docs/notebooks/random_seed.ipynb +++ b/docs/notebooks/random_seed.ipynb @@ -51,10 +51,7 @@ "from ramp.example.input_file_1 import User_list\n", "\n", "# Build use case 1 with non-fixed seed\n", - "uc_1 = UseCase(\n", - " users=deepcopy(User_list),\n", - " random_seed=None\n", - ")\n", + "uc_1 = UseCase(users=deepcopy(User_list), random_seed=None)\n", "# Initialize and generate load profile\n", "uc_1.initialize(peak_enlarge=0.15, num_days=3)\n", "uc_1_lp = uc_1.generate_daily_load_profiles()" @@ -92,19 +89,13 @@ "cell_type": "code", "source": [ "# Build use case 2 and fixed random seed\n", - "uc_2 = UseCase(\n", - " users=deepcopy(User_list),\n", - " random_seed=1\n", - ")\n", + "uc_2 = UseCase(users=deepcopy(User_list), random_seed=1)\n", "# Initialize and generate load profile\n", "uc_2.initialize(peak_enlarge=0.15, num_days=3)\n", "uc_2_lp = uc_2.generate_daily_load_profiles()\n", "\n", "# Build use case 3 and same fixed random seed as uc_2\n", - "uc_3 = UseCase(\n", - " users=deepcopy(User_list),\n", - " random_seed=1\n", - ")\n", + "uc_3 = UseCase(users=deepcopy(User_list), random_seed=1)\n", "\n", "# Initialize and generate load profile\n", "uc_3.initialize(peak_enlarge=0.15, num_days=3)\n", @@ -147,12 +138,17 @@ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "\n", - "lp_df = pd.DataFrame({'UseCase_1: non_fixed_seed': uc_1_lp,\n", - " 'UseCase_2: fixed_seed': uc_2_lp,\n", - " 'UseCase_3: fixed_seed': uc_3_lp,\n", - " 'diff UseCase_2 - UseCase_1': uc_2_lp - uc_1_lp, # difference between uc_1 and uc_2 is not zero\n", - " 'diff UseCase_2 - UseCase_3': uc_2_lp - uc_3_lp # difference between uc_2 and uc_3 is zero\n", - " })\n", + "lp_df = pd.DataFrame(\n", + " {\n", + " \"UseCase_1: non_fixed_seed\": uc_1_lp,\n", + " \"UseCase_2: fixed_seed\": uc_2_lp,\n", + " \"UseCase_3: fixed_seed\": uc_3_lp,\n", + " \"diff UseCase_2 - UseCase_1\": uc_2_lp\n", + " - uc_1_lp, # difference between uc_1 and uc_2 is not zero\n", + " \"diff UseCase_2 - UseCase_3\": uc_2_lp\n", + " - uc_3_lp, # difference between uc_2 and uc_3 is zero\n", + " }\n", + ")\n", "lp_df.plot()\n", "plt.show()" ], diff --git a/docs/notebooks/simple_bulb.ipynb b/docs/notebooks/simple_bulb.ipynb index 3d3cf48d..455f302e 100644 --- a/docs/notebooks/simple_bulb.ipynb +++ b/docs/notebooks/simple_bulb.ipynb @@ -69,16 +69,16 @@ "source": [ "# add_appliance is meth\n", "indoor_bulb = household.add_appliance(\n", - " name=\"Indoor Light Bulb\", # the name of the appliance\n", - " number=6, # how many of this appliance each user has in this user category\n", - " power=7, # the power (in Watt) of each single appliance. RAMP does not deal with units of measures, you should check the consistency of the unit of measures throughout your model\n", - " num_windows=2, # how many usage time windows throughout the day?\n", - " func_time=120, # the total usage time of appliances\n", - " func_cycle=10, # the minimum usage time after a switch on event\n", + " name=\"Indoor Light Bulb\", # the name of the appliance\n", + " number=6, # how many of this appliance each user has in this user category\n", + " power=7, # the power (in Watt) of each single appliance. RAMP does not deal with units of measures, you should check the consistency of the unit of measures throughout your model\n", + " num_windows=2, # how many usage time windows throughout the day?\n", + " func_time=120, # the total usage time of appliances\n", + " func_cycle=10, # the minimum usage time after a switch on event\n", " window_1=[0, 30], # from 24 to 00:30\n", " window_2=[1170, 1440], # from 19:30 to 24:00\n", - " random_var_w=0.35, # Variability of the windows in percentage\n", - " time_fraction_random_variability=0.2, # randomizes the total time the appliance is on (between 0 and 1)\n", + " random_var_w=0.35, # Variability of the windows in percentage\n", + " time_fraction_random_variability=0.2, # randomizes the total time the appliance is on (between 0 and 1)\n", ")" ] }, @@ -186,10 +186,12 @@ ], "source": [ "use_case = UseCase(\n", - " users=[household], # A list of all the user categories to be included in the simulation. In this case, we only have household user category\n", - " date_start=\"2020-01-01\", # starting date of the simulation\n", - " date_end=\"2020-12-31\", # end date of the simulation\n", - " )\n" + " users=[\n", + " household\n", + " ], # A list of all the user categories to be included in the simulation. In this case, we only have household user category\n", + " date_start=\"2020-01-01\", # starting date of the simulation\n", + " date_end=\"2020-12-31\", # end date of the simulation\n", + ")" ] }, { @@ -283,9 +285,7 @@ } ], "source": [ - "single_profile = household.generate_single_load_profile(\n", - " day_type=0\n", - " )" + "single_profile = household.generate_single_load_profile(day_type=0)" ] }, { @@ -337,9 +337,7 @@ "metadata": {}, "outputs": [], "source": [ - "aggregated_profile = household.generate_aggregated_load_profile(\n", - " day_type=0\n", - ")" + "aggregated_profile = household.generate_aggregated_load_profile(day_type=0)" ] }, { diff --git a/docs/notebooks/thermal_app.ipynb b/docs/notebooks/thermal_app.ipynb index 6a86f80b..39975b90 100644 --- a/docs/notebooks/thermal_app.ipynb +++ b/docs/notebooks/thermal_app.ipynb @@ -92,12 +92,12 @@ "shower = household.add_appliance(\n", " name=\"Shower\",\n", " number=1,\n", - " power=shower_power, # pass the pd.DataFrame or np.array instead of a number\n", - " num_windows=2, # two possibe time window for shower\n", - " func_time=15, # each shower takes 15 minute\n", - " func_cycle=3, # every\n", - " window_1=[390, 540], # morning shower from 6:30 to 9:00 AM\n", - " window_2=[1080, 1200], # evening shower from 18:00 to 20:00\n", + " power=shower_power, # pass the pd.DataFrame or np.array instead of a number\n", + " num_windows=2, # two possibe time window for shower\n", + " func_time=15, # each shower takes 15 minute\n", + " func_cycle=3, # every\n", + " window_1=[390, 540], # morning shower from 6:30 to 9:00 AM\n", + " window_2=[1080, 1200], # evening shower from 18:00 to 20:00\n", ")" ] }, @@ -156,7 +156,7 @@ "def thermal_p_var_sensitivity(sensitivity_values):\n", " # buidling a pd.DataFrame for saving sensitivity results\n", " results = pd.DataFrame(\n", - " index=range(0,1440*365),\n", + " index=range(0, 1440 * 365),\n", " columns=[f\"p_var = {value}\" for value in sensitivity_values],\n", " )\n", "\n", @@ -202,17 +202,20 @@ } ], "source": [ - "days_to_plot = [1,100,200] # which days of the year to plot\n", + "days_to_plot = [1, 100, 200] # which days of the year to plot\n", "\n", - "fig, axes = plt.subplots(ncols=len(days_to_plot), nrows=sensitivity_results.shape[1], figsize=(10, 10)) \n", + "fig, axes = plt.subplots(\n", + " ncols=len(days_to_plot), nrows=sensitivity_results.shape[1], figsize=(10, 10)\n", + ")\n", "\n", - "for j,day in enumerate(days_to_plot):\n", + "for j, day in enumerate(days_to_plot):\n", " for i, col in enumerate(sensitivity_results):\n", - " sensitivity_results[col].iloc[1440*(day-1):1440*(day)].plot(ax=axes[i,j]) # just plot for the first day\n", - " axes[i,j].set_title(f\"Day {day} - thermal_p_var = {col}\",fontsize=8)\n", - " axes[i,j].set_ylim(0,24000)\n", + " sensitivity_results[col].iloc[1440 * (day - 1) : 1440 * (day)].plot(\n", + " ax=axes[i, j]\n", + " ) # just plot for the first day\n", + " axes[i, j].set_title(f\"Day {day} - thermal_p_var = {col}\", fontsize=8)\n", + " axes[i, j].set_ylim(0, 24000)\n", "\n", - " \n", "\n", "plt.tight_layout()\n", "plt.show()" diff --git a/ramp/core/core.py b/ramp/core/core.py index 3814d75d..5faedae6 100644 --- a/ramp/core/core.py +++ b/ramp/core/core.py @@ -694,7 +694,7 @@ 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 ---------- diff --git a/ramp/example/input_file_1.py b/ramp/example/input_file_1.py index 9d83c176..f50ba444 100644 --- a/ramp/example/input_file_1.py +++ b/ramp/example/input_file_1.py @@ -46,7 +46,16 @@ # Create new appliances # Church -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 = 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.add_appliance(7, 26, 1, 150, 0.2, 60, "yes", flat="yes") @@ -59,7 +68,9 @@ 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.add_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) diff --git a/ramp/example/input_file_2.py b/ramp/example/input_file_2.py index 83878573..b8479ba8 100644 --- a/ramp/example/input_file_2.py +++ b/ramp/example/input_file_2.py @@ -22,7 +22,15 @@ User_list.append(HH) HH_shower_P = pd.read_csv("ramp/example/shower_P.csv") -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 = 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) diff --git a/ramp/example/input_file_3.py b/ramp/example/input_file_3.py index 74441eaf..b7f165f3 100644 --- a/ramp/example/input_file_3.py +++ b/ramp/example/input_file_3.py @@ -25,7 +25,15 @@ # Create Cooking appliances HH_lunch1_soup = HH.add_appliance( - number=1, power=1800, num_windows=2, func_time=70, time_fraction_random_variability=0.15, func_cycle=60, thermal_p_var=0.2, pref_index=1, fixed_cycle=1 + number=1, + power=1800, + num_windows=2, + func_time=70, + time_fraction_random_variability=0.15, + func_cycle=60, + thermal_p_var=0.2, + pref_index=1, + fixed_cycle=1, ) HH_lunch1_soup.windows(window_1=[12 * 60, 15 * 60], window_2=[0, 0], random_var_w=0.15) HH_lunch1_soup.specific_cycle_1(p_11=1800, t_11=10, p_12=750, t_12=60, r_c1=0.15) From 7ad9f3919d39c587d091328bc839fc5e4125f469 Mon Sep 17 00:00:00 2001 From: "pierre-francois.duc" Date: Tue, 14 May 2024 14:48:31 +0200 Subject: [PATCH 8/8] Update documentation notebooks --- .../examples/cooking_app/cooking_app.rst | 33 +++++++++-------- .../fixed_flat_app/fixed_flat_app.rst | 20 +++++------ .../examples/multi_cycle/multi_cycle.rst | 26 ++++---------- .../occasional_use/occasional_use.rst | 33 ++++++++--------- .../examples/simple_bulb/simple_bulb.rst | 35 +++++++++---------- .../examples/thermal_app/thermal_app.rst | 31 ++++++++-------- 6 files changed, 80 insertions(+), 98 deletions(-) diff --git a/docs/source/examples/cooking_app/cooking_app.rst b/docs/source/examples/cooking_app/cooking_app.rst index e6afec8c..530dba18 100644 --- a/docs/source/examples/cooking_app/cooking_app.rst +++ b/docs/source/examples/cooking_app/cooking_app.rst @@ -72,20 +72,20 @@ Cooking rice 600 10 .. code:: ipython3 # soup for lunch - lunch_window = [12 * 60, 12 * 60+26] + lunch_window = [12 * 60, 12 * 60 + 26] soup_1 = user_1.add_appliance( name="soup for lunch", - power=1200, # nominal power of appliance - func_time=25, # the cooking time - func_cycle=25, # we always need 25 minute for cooking - fixed_cycle=1, # the cookstove is not a continus power usage appliance, it has cycles as mentioned earlier - window_1=lunch_window, # lunch is always prepared from 12 + power=1200, # nominal power of appliance + func_time=25, # the cooking time + func_cycle=25, # we always need 25 minute for cooking + fixed_cycle=1, # the cookstove is not a continus power usage appliance, it has cycles as mentioned earlier + window_1=lunch_window, # lunch is always prepared from 12 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=lunch_window, # the time window of the working cycle + cw11=lunch_window, # the time window of the working cycle ) The second user has two different preferences for lunch. Accordingly, we @@ -142,10 +142,9 @@ rice is the second one (pref_index = 2). number_of_days = 5 user_1_profiles = {} user_2_profiles = {} - for day in range(1,number_of_days+1): + for day in range(1, number_of_days + 1): user_1_profiles[f"day {day}"] = pd.Series(user_1.generate_single_load_profile()) user_2_profiles[f"day {day}"] = pd.Series(user_2.generate_single_load_profile()) - .. parsed-literal:: @@ -156,17 +155,21 @@ rice is the second one (pref_index = 2). .. code:: ipython3 - fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) + fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) i = 0 for name, df in dict( - user_1_profiles=pd.concat(user_1_profiles,axis=1).iloc[lunch_window[0]-5:lunch_window[1]+5], # take only the lunch window - user_2_profiles=pd.concat(user_2_profiles,axis=1).iloc[lunch_window[0]-5:lunch_window[1]+5]# take only the lunch window - ).items(): - df.plot(ax=axes[i],legend=True) + user_1_profiles=pd.concat(user_1_profiles, axis=1).iloc[ + lunch_window[0] - 5 : lunch_window[1] + 5 + ], # take only the lunch window + user_2_profiles=pd.concat(user_2_profiles, axis=1).iloc[ + lunch_window[0] - 5 : lunch_window[1] + 5 + ], # take only the lunch window + ).items(): + df.plot(ax=axes[i], legend=True) axes[i].set_title(name) - i+=1 + i += 1 plt.tight_layout() plt.show() 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 18bca4aa..4af34757 100644 --- a/docs/source/examples/fixed_flat_app/fixed_flat_app.rst +++ b/docs/source/examples/fixed_flat_app/fixed_flat_app.rst @@ -43,10 +43,9 @@ Adding an appliance with flat and fixed consumption 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 - window_1 = [1200, 1440], # from 20:00 to 24:00 + window_1=[1200, 1440], # from 20:00 to 24:00 ) - Generating the profiles using UseCase class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -58,14 +57,12 @@ number of days for generating the profiles: .. code:: ipython3 school_case = UseCase( - users=[school], # users of the usecase - date_start="2023-01-01", # start date - ) + users=[school], # users of the usecase + date_start="2023-01-01", # start date + ) # when both date_start and date_end are not given, you need to initialize the usecase by this method and by passing the number of days as num_days - school_case.initialize( - num_days=7 - ) + school_case.initialize(num_days=7) .. parsed-literal:: @@ -144,12 +141,11 @@ overall energy consumption and demand patterns within simulation. .. code:: ipython3 - - fig, axes = plt.subplots(nrows=1, ncols=4, figsize=(12, 4)) + fig, axes = plt.subplots(nrows=1, ncols=4, figsize=(12, 4)) - for i, df in enumerate([no_fix_no_flat,fix_no_flat,fixed_flat,no_fixed_flat]): - df.plot(ax=axes[i],legend=False) + for i, df in enumerate([no_fix_no_flat, fix_no_flat, fixed_flat, no_fixed_flat]): + df.plot(ax=axes[i], legend=False) axes[i].set_title(df.columns[0]) diff --git a/docs/source/examples/multi_cycle/multi_cycle.rst b/docs/source/examples/multi_cycle/multi_cycle.rst index 867e5339..d281b3f6 100644 --- a/docs/source/examples/multi_cycle/multi_cycle.rst +++ b/docs/source/examples/multi_cycle/multi_cycle.rst @@ -85,30 +85,18 @@ example, we do not apply such variability. # assiging the specific cycles # first cycle: standard cycle fridge.specific_cycle_1( - p_11=200, # power level for the first operation segment + p_11=200, # power level for the first operation segment t_11=10, # duration of the first operation segment - p_12=5, # power level for the second operation segment + p_12=5, # power level for the second operation segment t_12=20, # duration of the second operation segment - r_c1=0 # random variability assigned to the duration of each segment + r_c1=0, # random variability assigned to the duration of each segment ) # second cycle: intermediate cycle - fridge.specific_cycle_2( - p_21=200, - t_21=15, - p_22=5, - t_22=15, - r_c2=0 - ) + fridge.specific_cycle_2(p_21=200, t_21=15, p_22=5, t_22=15, r_c2=0) # third cycle: intensive cycle - fridge.specific_cycle_3( - p_31=200, - t_31=20, - p_32=5, - t_32=10, - r_c3=0 - ) + fridge.specific_cycle_3(p_31=200, t_31=20, p_32=5, t_32=10, r_c3=0) After defining the cycle power and duration parameters, the time windows within a day at which the cycles occur should be specified by means of @@ -123,7 +111,7 @@ across all cycles should not overlap. # defining cycle behaviour fridge.cycle_behaviour( - cw11=[0, 299], cw12=[1201, 1440], cw21=[300, 479], cw31=[480, 1200] + cw11=[0, 299], cw12=[1201, 1440], cw21=[300, 479], cw31=[480, 1200] ) Building the profiles @@ -138,7 +126,7 @@ Building the profiles # days to build the profiles days = [ - "2020-12-16", # a day in the 'Hot' season, assuming a location in the Southern hemisphere + "2020-12-16", # a day in the 'Hot' season, assuming a location in the Southern hemisphere ] profiles = pd.DataFrame(index=range(0, 1440), columns=days) diff --git a/docs/source/examples/occasional_use/occasional_use.rst b/docs/source/examples/occasional_use/occasional_use.rst index db1bd0f0..9b17d129 100644 --- a/docs/source/examples/occasional_use/occasional_use.rst +++ b/docs/source/examples/occasional_use/occasional_use.rst @@ -39,10 +39,10 @@ Creating user categories and appliances number=1, power=50, num_windows=1, - func_time=210, # 3.5 hours - func_cycle=210, + func_time=210, # 3.5 hours + func_cycle=210, occasional_use=0.5, # 50% chance of occasional use, - window_1=[480, 750], # start from 8AM + window_1=[480, 750], # start from 8AM ) .. code:: ipython3 @@ -52,10 +52,10 @@ Creating user categories and appliances number=1, power=50, num_windows=1, - func_time=210, # 3.5 hours - func_cycle=210, + func_time=210, # 3.5 hours + func_cycle=210, occasional_use=1, # always present in the mix of appliances, - window_1=[480, 750], # start from 8AM + window_1=[480, 750], # start from 8AM ) Generating profiles @@ -70,14 +70,10 @@ the User object profile genertor methods for 5 consecutive days: household_profiles = [] school_profiles = [] - for day in range(1,number_of_days+1): - household_profiles.extend( - household.generate_single_load_profile(prof_i=day) - ) + for day in range(1, number_of_days + 1): + household_profiles.extend(household.generate_single_load_profile(prof_i=day)) - school_profiles.extend( - school.generate_single_load_profile(prof_i=day) - ) + school_profiles.extend(school.generate_single_load_profile(prof_i=day)) .. parsed-literal:: @@ -88,24 +84,23 @@ the User object profile genertor methods for 5 consecutive days: .. code:: ipython3 - fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) + fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4)) i = 0 for name, df in dict( household_profiles=pd.DataFrame(household_profiles), - school_profiles=pd.DataFrame(school_profiles) - ).items(): - df.plot(ax=axes[i],legend=False) + school_profiles=pd.DataFrame(school_profiles), + ).items(): + df.plot(ax=axes[i], legend=False) axes[i].set_title(name) - i+=1 + i += 1 plt.tight_layout() plt.show() - .. image:: output_8_0.png diff --git a/docs/source/examples/simple_bulb/simple_bulb.rst b/docs/source/examples/simple_bulb/simple_bulb.rst index eb623922..ff57a1bc 100644 --- a/docs/source/examples/simple_bulb/simple_bulb.rst +++ b/docs/source/examples/simple_bulb/simple_bulb.rst @@ -56,16 +56,16 @@ using the **add_appliance** method of the User object: # add_appliance is meth indoor_bulb = household.add_appliance( - name="Indoor Light Bulb", # the name of the appliance - number=6, # how many of this appliance each user has in this user category - power=7, # the power (in Watt) of each single appliance. RAMP does not deal with units of measures, you should check the consistency of the unit of measures throughout your model - num_windows=2, # how many usage time windows throughout the day? - func_time=120, # the total usage time of appliances - func_cycle=10, # the minimum usage time after a switch on event + name="Indoor Light Bulb", # the name of the appliance + number=6, # how many of this appliance each user has in this user category + power=7, # the power (in Watt) of each single appliance. RAMP does not deal with units of measures, you should check the consistency of the unit of measures throughout your model + num_windows=2, # how many usage time windows throughout the day? + func_time=120, # the total usage time of appliances + func_cycle=10, # the minimum usage time after a switch on event window_1=[0, 30], # from 24 to 00:30 window_2=[1170, 1440], # from 19:30 to 24:00 - random_var_w=0.35, # Variability of the windows in percentage - time_fraction_random_variability=0.2, # randomizes the total time the appliance is on (between 0 and 1) + random_var_w=0.35, # Variability of the windows in percentage + time_fraction_random_variability=0.2, # randomizes the total time the appliance is on (between 0 and 1) ) .. code:: ipython3 @@ -127,11 +127,12 @@ comprehensive profile spanning the entire year: .. code:: ipython3 use_case = UseCase( - users=[household], # A list of all the user categories to be included in the simulation. In this case, we only have household user category - date_start="2020-01-01", # starting date of the simulation - date_end="2020-12-31", # end date of the simulation - ) - + users=[ + household + ], # A list of all the user categories to be included in the simulation. In this case, we only have household user category + date_start="2020-01-01", # starting date of the simulation + date_end="2020-12-31", # end date of the simulation + ) .. parsed-literal:: @@ -200,9 +201,7 @@ within the household category: .. code:: ipython3 - single_profile = household.generate_single_load_profile( - day_type=0 - ) + single_profile = household.generate_single_load_profile(day_type=0) .. parsed-literal:: @@ -238,9 +237,7 @@ can use the similar method of User class, named .. code:: ipython3 - aggregated_profile = household.generate_aggregated_load_profile( - day_type=0 - ) + aggregated_profile = household.generate_aggregated_load_profile(day_type=0) .. code:: ipython3 diff --git a/docs/source/examples/thermal_app/thermal_app.rst b/docs/source/examples/thermal_app/thermal_app.rst index d7cb9dc0..26903dc3 100644 --- a/docs/source/examples/thermal_app/thermal_app.rst +++ b/docs/source/examples/thermal_app/thermal_app.rst @@ -52,12 +52,12 @@ load_data util function: shower = household.add_appliance( name="Shower", number=1, - power=shower_power, # pass the pd.DataFrame or np.array instead of a number - num_windows=2, # two possibe time window for shower - func_time=15, # each shower takes 15 minute - func_cycle=3, # every - window_1=[390, 540], # morning shower from 6:30 to 9:00 AM - window_2=[1080, 1200], # evening shower from 18:00 to 20:00 + power=shower_power, # pass the pd.DataFrame or np.array instead of a number + num_windows=2, # two possibe time window for shower + func_time=15, # each shower takes 15 minute + func_cycle=3, # every + window_1=[390, 540], # morning shower from 6:30 to 9:00 AM + window_2=[1080, 1200], # evening shower from 18:00 to 20:00 ) Generating profiles for increasing degrees of ``thermal_p_var`` @@ -97,7 +97,7 @@ function **thermal_p_var_sensitivty**: def thermal_p_var_sensitivity(sensitivity_values): # buidling a pd.DataFrame for saving sensitivity results results = pd.DataFrame( - index=range(0,1440*365), + index=range(0, 1440 * 365), columns=[f"p_var = {value}" for value in sensitivity_values], ) @@ -120,17 +120,20 @@ function **thermal_p_var_sensitivty**: .. code:: ipython3 - days_to_plot = [1,100,200] # which days of the year to plot + days_to_plot = [1, 100, 200] # which days of the year to plot - fig, axes = plt.subplots(ncols=len(days_to_plot), nrows=sensitivity_results.shape[1], figsize=(10, 10)) + fig, axes = plt.subplots( + ncols=len(days_to_plot), nrows=sensitivity_results.shape[1], figsize=(10, 10) + ) - for j,day in enumerate(days_to_plot): + for j, day in enumerate(days_to_plot): for i, col in enumerate(sensitivity_results): - sensitivity_results[col].iloc[1440*(day-1):1440*(day)].plot(ax=axes[i,j]) # just plot for the first day - axes[i,j].set_title(f"Day {day} - thermal_p_var = {col}",fontsize=8) - axes[i,j].set_ylim(0,24000) + sensitivity_results[col].iloc[1440 * (day - 1) : 1440 * (day)].plot( + ax=axes[i, j] + ) # just plot for the first day + axes[i, j].set_title(f"Day {day} - thermal_p_var = {col}", fontsize=8) + axes[i, j].set_ylim(0, 24000) - plt.tight_layout() plt.show()